mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
show/hide of login buttons
This commit is contained in:
parent
0e75c80627
commit
7a131880e5
@ -27,7 +27,7 @@
|
|||||||
<p class="text-3xl text-white text-center mb-4">{{ $strings.HeaderLogin }}</p>
|
<p class="text-3xl text-white text-center mb-4">{{ $strings.HeaderLogin }}</p>
|
||||||
<div class="w-full h-px bg-white bg-opacity-10 my-4" />
|
<div class="w-full h-px bg-white bg-opacity-10 my-4" />
|
||||||
<p v-if="error" class="text-error text-center py-2">{{ error }}</p>
|
<p v-if="error" class="text-error text-center py-2">{{ error }}</p>
|
||||||
<form id="login-local" @submit.prevent="submitForm">
|
<form v-show="login_local" @submit.prevent="submitForm">
|
||||||
<label class="text-xs text-gray-300 uppercase">{{ $strings.LabelUsername }}</label>
|
<label class="text-xs text-gray-300 uppercase">{{ $strings.LabelUsername }}</label>
|
||||||
<ui-text-input v-model="username" :disabled="processing" class="mb-3 w-full" />
|
<ui-text-input v-model="username" :disabled="processing" class="mb-3 w-full" />
|
||||||
|
|
||||||
@ -39,10 +39,10 @@
|
|||||||
</form>
|
</form>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="w-full flex py-3">
|
<div class="w-full flex py-3">
|
||||||
<a id="login-google-oauth20" :href="`http://localhost:3333/auth/google?callback=${currentUrl}`">
|
<a v-show="login_google_oauth20" :href="`http://localhost:3333/auth/google?callback=${currentUrl}`">
|
||||||
<ui-btn color="primary" class="leading-none">Login with Google</ui-btn>
|
<ui-btn color="primary" class="leading-none">Login with Google</ui-btn>
|
||||||
</a>
|
</a>
|
||||||
<a id="login-openid" :href="`http://localhost:3333/auth/openid?callback=${currentUrl}`">
|
<a v-show="login_openid" :href="`http://localhost:3333/auth/openid?callback=${currentUrl}`">
|
||||||
<ui-btn color="primary" class="leading-none">Login with OpenId</ui-btn>
|
<ui-btn color="primary" class="leading-none">Login with OpenId</ui-btn>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -70,7 +70,10 @@ export default {
|
|||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
ConfigPath: '',
|
ConfigPath: '',
|
||||||
MetadataPath: '',
|
MetadataPath: '',
|
||||||
currentUrl: location.toString()
|
currentUrl: location.toString(),
|
||||||
|
login_local: true,
|
||||||
|
login_google_oauth20: false,
|
||||||
|
login_openid: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -227,14 +230,23 @@ export default {
|
|||||||
await this.$axios
|
await this.$axios
|
||||||
.$get('/auth_methods')
|
.$get('/auth_methods')
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
;['local', 'google-oauth20', 'openid'].forEach((auth_method) => {
|
if (response.includes('local')) {
|
||||||
debugger
|
this.login_local = true
|
||||||
if (response.includes(auth_method)) {
|
|
||||||
// TODO: show `#login-${auth_method}`
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: hide `#login-${auth_method}`
|
this.login_local = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.includes('google-oauth20')) {
|
||||||
|
this.login_google_oauth20 = true
|
||||||
|
} else {
|
||||||
|
this.login_google_oauth20 = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.includes('openid')) {
|
||||||
|
this.login_openid = true
|
||||||
|
} else {
|
||||||
|
this.login_openid = false
|
||||||
}
|
}
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed', error.response)
|
console.error('Failed', error.response)
|
||||||
@ -243,7 +255,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.updateLoginVisibility()
|
this.$nextTick(async () => await this.updateLoginVisibility())
|
||||||
if (new URLSearchParams(window.location.search).get('setToken')) {
|
if (new URLSearchParams(window.location.search).get('setToken')) {
|
||||||
localStorage.setItem('token', new URLSearchParams(window.location.search).get('setToken'))
|
localStorage.setItem('token', new URLSearchParams(window.location.search).get('setToken'))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user