This commit is contained in:
Jeidnx 2024-01-29 10:24:02 +01:00 committed by GitHub
commit 9c66e2a7e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View file

@ -28,6 +28,11 @@
<div>
<a v-t="'titles.login'" class="btn w-auto" @click="login" />
</div>
<ul class="children:pb-3">
<li v-for="provider in oidcProviders" :key="provider.name">
<a class="btn" :href="provider.authUri">Log in with {{ provider.name }}</a>
</li>
</ul>
<TooltipIcon icon="i-fa6-solid:circle-info" :tooltip="$t('info.login_note')" />
</form>
</div>
@ -44,9 +49,16 @@ export default {
return {
username: null,
password: null,
oidcProviders: null,
};
},
mounted() {
const session = this.$route.query.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("/");
@ -56,6 +68,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,
authUri: `${this.authApiUrl()}/oidc/${name}/login?redirect=${window.location.origin}/login`,
};
});
});
},
login() {
if (!this.username || !this.password) return;
this.fetchJson(this.authApiUrl() + "/login", null, {

View file

@ -502,6 +502,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 => {
@ -647,7 +648,8 @@ export default {
}),
}).then(resp => {
if (!resp.error) {
this.logout();
const redirect = resp.redirect;
redirect ? (location.href = redirect) : this.logout();
} else alert(resp.error);
});
},