From 057d28f54eddede3722b6cb513f26a0ba7ae27bf Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Thu, 25 Jun 2020 07:58:33 +0200
Subject: [PATCH] Set target-origin parameter for Nextcloud popup (#8)

---
 packages/file-handling/src/vpu-nextcloud-file-picker.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/packages/file-handling/src/vpu-nextcloud-file-picker.js b/packages/file-handling/src/vpu-nextcloud-file-picker.js
index 02d68f53..b83c5c42 100644
--- a/packages/file-handling/src/vpu-nextcloud-file-picker.js
+++ b/packages/file-handling/src/vpu-nextcloud-file-picker.js
@@ -155,7 +155,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
     openFilePicker() {
         // TODO: translation
         this.statusText = "Auth in progress";
-        this.loginWindow = window.open(this.authUrl, "Nextcloud Login",
+        const authUrl = this.authUrl + "?target-origin=" + encodeURIComponent(window.location.href);
+        this.loginWindow = window.open(authUrl, "Nextcloud Login",
             "width=400,height=400,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
     }
 
-- 
GitLab