From e38b31bf97c994f5e212fde15c7420c3c68306b5 Mon Sep 17 00:00:00 2001 From: Jeidnx Date: Sun, 18 Jun 2023 18:32:52 +0200 Subject: [PATCH 1/4] Add support for oidc --- src/components/LoginPage.vue | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index d7d28753..45966fda 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -28,6 +28,11 @@
+ @@ -38,9 +43,18 @@ export default { return { username: null, password: null, + oidcProviders: null, }; }, mounted() { + //TODO: Maybe there is a better way to do this? + const urlParams = new URLSearchParams(window.location.search); + const session = urlParams.get("session"); + if (session) { + this.setPreference("authToken" + this.hashCode(this.authApiUrl()), session); + this.$router.push("/"); + } + this.fetchConfig(); //TODO: Add Server Side check if (this.getAuthToken()) { this.$router.push("/"); @@ -50,6 +64,16 @@ export default { document.title = this.$t("titles.login") + " - Piped"; }, methods: { + async fetchConfig() { + this.fetchJson(this.apiUrl() + "/config").then(config => { + this.oidcProviders = config?.oidcProviders.map(name => { + return { + name, + authUrl: `${this.authApiUrl()}/oidc/${name}/login`, + }; + }); + }); + }, login() { if (!this.username || !this.password) return; this.fetchJson(this.authApiUrl() + "/login", null, { From 0efeff00983ca8c2483d5a03a6f69878632643e2 Mon Sep 17 00:00:00 2001 From: Jeidnx Date: Mon, 19 Jun 2023 18:25:58 +0200 Subject: [PATCH 2/4] Include redirect parameter in link --- src/components/LoginPage.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index 45966fda..9244e903 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -30,7 +30,7 @@ @@ -69,7 +69,7 @@ export default { this.oidcProviders = config?.oidcProviders.map(name => { return { name, - authUrl: `${this.authApiUrl()}/oidc/${name}/login`, + authUri: `${this.authApiUrl()}/oidc/${name}/login?redirect=${window.location.origin}/login`, }; }); }); From f8fc281284e8b200599ec8b73f70a3a407855b65 Mon Sep 17 00:00:00 2001 From: Jeidnx Date: Thu, 26 Oct 2023 13:43:19 +0200 Subject: [PATCH 3/4] Add oidc delete capability --- src/components/LoginPage.vue | 4 +--- src/components/PreferencesPage.vue | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index 9244e903..9a12344c 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -47,9 +47,7 @@ export default { }; }, mounted() { - //TODO: Maybe there is a better way to do this? - const urlParams = new URLSearchParams(window.location.search); - const session = urlParams.get("session"); + const session = this.$route.query.session; if (session) { this.setPreference("authToken" + this.hashCode(this.authApiUrl()), session); this.$router.push("/"); diff --git a/src/components/PreferencesPage.vue b/src/components/PreferencesPage.vue index 06ee1192..6f08a680 100644 --- a/src/components/PreferencesPage.vue +++ b/src/components/PreferencesPage.vue @@ -473,6 +473,7 @@ export default { document.title = this.$t("titles.preferences") + " - Piped"; }, async mounted() { + if (this.$route.query.deleted == this.getAuthToken()) this.logout(); if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} }); this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => { @@ -611,7 +612,8 @@ export default { }), }).then(resp => { if (!resp.error) { - this.logout(); + const redirect = resp.redirect; + redirect ? (location.href = redirect) : this.logout(); } else alert(resp.error); }); }, From 344ae7d06fc4f857400ade647d121a49a615ad76 Mon Sep 17 00:00:00 2001 From: Jeidnx Date: Thu, 26 Oct 2023 14:22:07 +0200 Subject: [PATCH 4/4] fix css --- src/components/LoginPage.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index 4b4b0142..a026cb4f 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -28,9 +28,9 @@
-