mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Merge 344ae7d06f into 564d59427e
				
					
				
			This commit is contained in:
		
						commit
						9c66e2a7e3
					
				
					 2 changed files with 25 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,6 +28,11 @@
 | 
				
			||||||
            <div>
 | 
					            <div>
 | 
				
			||||||
                <a v-t="'titles.login'" class="btn w-auto" @click="login" />
 | 
					                <a v-t="'titles.login'" class="btn w-auto" @click="login" />
 | 
				
			||||||
            </div>
 | 
					            </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')" />
 | 
					            <TooltipIcon icon="i-fa6-solid:circle-info" :tooltip="$t('info.login_note')" />
 | 
				
			||||||
        </form>
 | 
					        </form>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
| 
						 | 
					@ -44,9 +49,16 @@ export default {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            username: null,
 | 
					            username: null,
 | 
				
			||||||
            password: null,
 | 
					            password: null,
 | 
				
			||||||
 | 
					            oidcProviders: null,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    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
 | 
					        //TODO: Add Server Side check
 | 
				
			||||||
        if (this.getAuthToken()) {
 | 
					        if (this.getAuthToken()) {
 | 
				
			||||||
            this.$router.push("/");
 | 
					            this.$router.push("/");
 | 
				
			||||||
| 
						 | 
					@ -56,6 +68,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,
 | 
				
			||||||
 | 
					                        authUri: `${this.authApiUrl()}/oidc/${name}/login?redirect=${window.location.origin}/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, {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -502,6 +502,7 @@ export default {
 | 
				
			||||||
        document.title = this.$t("titles.preferences") + " - Piped";
 | 
					        document.title = this.$t("titles.preferences") + " - Piped";
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    async mounted() {
 | 
					    async mounted() {
 | 
				
			||||||
 | 
					        if (this.$route.query.deleted == this.getAuthToken()) this.logout();
 | 
				
			||||||
        if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
 | 
					        if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => {
 | 
					        this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => {
 | 
				
			||||||
| 
						 | 
					@ -647,7 +648,8 @@ export default {
 | 
				
			||||||
                }),
 | 
					                }),
 | 
				
			||||||
            }).then(resp => {
 | 
					            }).then(resp => {
 | 
				
			||||||
                if (!resp.error) {
 | 
					                if (!resp.error) {
 | 
				
			||||||
                    this.logout();
 | 
					                    const redirect = resp.redirect;
 | 
				
			||||||
 | 
					                    redirect ? (location.href = redirect) : this.logout();
 | 
				
			||||||
                } else alert(resp.error);
 | 
					                } else alert(resp.error);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue