7a137 google auth (#520)
* google oauth * fix lint * cleanup debug * Oauth changes, alert message, email validation * fix exception and inline return condition * fix google oauth * UI fixes * fix provider user --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
30
client/stores/oauth_providers.js
vendored
30
client/stores/oauth_providers.js
vendored
@@ -61,6 +61,33 @@ export const useOAuthProvidersStore = defineStore("oauth_providers", () => {
|
||||
})
|
||||
}
|
||||
|
||||
const guestConnect = (service, redirect = false) => {
|
||||
contentStore.resetState()
|
||||
contentStore.startLoading()
|
||||
|
||||
const intention = new URL(window.location.href).pathname
|
||||
|
||||
opnFetch(`/oauth/connect/${service}`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
...redirect ? { intention } : {},
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
window.location.href = data.url
|
||||
})
|
||||
.catch((error) => {
|
||||
try {
|
||||
alert.error(error.data.message)
|
||||
} catch (e) {
|
||||
alert.error("An error occurred while connecting an account")
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
contentStore.stopLoading()
|
||||
})
|
||||
}
|
||||
|
||||
const providers = computed(() => contentStore.getAll.value)
|
||||
|
||||
return {
|
||||
@@ -69,6 +96,7 @@ export const useOAuthProvidersStore = defineStore("oauth_providers", () => {
|
||||
getService,
|
||||
fetchOAuthProviders,
|
||||
providers,
|
||||
connect
|
||||
connect,
|
||||
guestConnect
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user