From e38b31bf97c994f5e212fde15c7420c3c68306b5 Mon Sep 17 00:00:00 2001 From: Jeidnx Date: Sun, 18 Jun 2023 18:32:52 +0200 Subject: [PATCH] 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, {