diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue
index 459c79b673..0f5338ec0e 100644
--- a/src/components/LoginPage.vue
+++ b/src/components/LoginPage.vue
@@ -31,6 +31,11 @@
+
@@ -41,10 +46,17 @@ export default {
return {
username: null,
password: null,
+ oidcProviders: null,
};
},
mounted() {
- //TODO: Add Server Side check
+ const session = this.$route.query.session;
+ if (session) {
+ this.setPreference("authToken" + this.hashCode(this.authApiUrl()), session);
+ this.setPreference("isOidcLogin", true);
+ window.location = import.meta.env.BASE_URL;
+ }
+ this.fetchConfig();
if (this.getAuthToken()) {
this.$router.push(import.meta.env.BASE_URL);
}
@@ -53,6 +65,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, {
diff --git a/src/components/PreferencesPage.vue b/src/components/PreferencesPage.vue
index eae7f63c56..0ed34b9324 100644
--- a/src/components/PreferencesPage.vue
+++ b/src/components/PreferencesPage.vue
@@ -330,6 +330,7 @@
0) this.$router.replace({ query: {} });
+ const token = this.getAuthToken();
+ if (token && this.$route.query.deleted == token) this.logout();
+
this.fetchInstances();
if (this.testLocalStorage) {
this.selectedInstance = this.getPreferenceString("instance", import.meta.env.VITE_PIPED_API);
this.authInstance = this.getPreferenceBoolean("authInstance", false);
this.selectedAuthInstance = this.getPreferenceString("auth_instance_url", this.selectedInstance);
+ this.isOidcLogin = this.getPreferenceBoolean("isOidcLogin", false);
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
var skipOptions, skipList;
@@ -668,6 +678,13 @@ export default {
return "https://www.ssllabs.com/ssltest/analyze.html?d=" + new URL(url).host + "&latest";
},
async deleteAccount() {
+ if (this.getPreferenceBoolean("isOidcLogin", false)) {
+ const url = new URL("/user/delete", this.authApiUrl());
+ url.searchParams.append("session", this.getAuthToken());
+ url.searchParams.append("redirect", `${window.location.origin}/preferences`);
+ window.location = url.href;
+ return;
+ }
this.fetchJson(this.authApiUrl() + "/user/delete", null, {
method: "POST",
headers: {
@@ -685,6 +702,8 @@ export default {
logout() {
// reset the auth token
localStorage.removeItem("authToken" + this.hashCode(this.authApiUrl()));
+ // Remove oidc state
+ localStorage.removeItem("isOidcLogin");
// redirect to trending page
window.location = import.meta.env.BASE_URL;
},