mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Add support for oidc
This commit is contained in:
parent
299f9906b4
commit
e38b31bf97
1 changed files with 24 additions and 0 deletions
|
@ -28,6 +28,11 @@
|
||||||
<div>
|
<div>
|
||||||
<a class="btn w-auto" @click="login" v-t="'titles.login'" />
|
<a class="btn w-auto" @click="login" v-t="'titles.login'" />
|
||||||
</div>
|
</div>
|
||||||
|
<ul class="md:flex-1 md:justify-center md:flex">
|
||||||
|
<li v-for="provider in oidcProviders" :key="provider.name">
|
||||||
|
<a class="btn w-auto" :href="provider.authUrl">Log in with {{ provider.name }}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -38,9 +43,18 @@ export default {
|
||||||
return {
|
return {
|
||||||
username: null,
|
username: null,
|
||||||
password: null,
|
password: null,
|
||||||
|
oidcProviders: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
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
|
//TODO: Add Server Side check
|
||||||
if (this.getAuthToken()) {
|
if (this.getAuthToken()) {
|
||||||
this.$router.push("/");
|
this.$router.push("/");
|
||||||
|
@ -50,6 +64,16 @@ export default {
|
||||||
document.title = this.$t("titles.login") + " - Piped";
|
document.title = this.$t("titles.login") + " - Piped";
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
login() {
|
||||||
if (!this.username || !this.password) return;
|
if (!this.username || !this.password) return;
|
||||||
this.fetchJson(this.authApiUrl() + "/login", null, {
|
this.fetchJson(this.authApiUrl() + "/login", null, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue