mirror of
https://github.com/linuxserver/heimdalljs.git
synced 2026-02-20 05:12:24 +08:00
added in code to prompt for multifactor auth at login if it is enabled for the user
This commit is contained in:
parent
11fb54bf83
commit
a1c2103dec
@ -61,6 +61,8 @@
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
<q-input v-if="loginStatus === 'multifactor'" v-model="totp" :label="this.$t('totp')" outlined>
|
||||
</q-input>
|
||||
<q-btn @click="login" unelevated color="cyan-8" style="padding: 10px;" class="full-width">Login</q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
@ -98,6 +100,10 @@ export default {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
loginStatus () {
|
||||
console.log(this.$store.state.app.loginStatus)
|
||||
return this.$store.state.app.loginStatus
|
||||
}
|
||||
},
|
||||
|
||||
@ -107,6 +113,7 @@ export default {
|
||||
selecteduser: null,
|
||||
username: null,
|
||||
password: '',
|
||||
totp: null,
|
||||
isPwd: true
|
||||
}
|
||||
},
|
||||
@ -115,11 +122,13 @@ export default {
|
||||
selectUser () {
|
||||
this.$store.dispatch('app/setUser', this.selecteduser)
|
||||
},
|
||||
login () {
|
||||
|
||||
async login () {
|
||||
const username = (this.show_usernames === true) ? this.selecteduser.username : this.username
|
||||
this.$store.dispatch('app/login', {
|
||||
username: username,
|
||||
password: this.password
|
||||
password: this.password,
|
||||
totp: this.totp || ''
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@ -78,22 +78,33 @@ export function setUser (context, user) {
|
||||
|
||||
export async function firelogin (context, data) {
|
||||
const response = await axios.post(process.env.BACKEND_LOCATION + 'login', data)
|
||||
// console.log(response.data)
|
||||
Cookies.set('jwt', response.data.result.token, {
|
||||
expires: 3600
|
||||
})
|
||||
if (response.data.result && response.data.result.token) {
|
||||
Cookies.set('jwt', response.data.result.token, {
|
||||
expires: 3600
|
||||
})
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
export async function login (context, data) {
|
||||
// console.log(data)
|
||||
try {
|
||||
await firelogin(context, data)
|
||||
const response = await firelogin(context, data)
|
||||
switch (response.data.status) {
|
||||
case 'ok':
|
||||
ping(context)
|
||||
context.commit('setLoginStatus', 'logged_in')
|
||||
break
|
||||
case 'multifactor':
|
||||
context.commit('setLoginStatus', 'multifactor')
|
||||
break
|
||||
}
|
||||
ping(context)
|
||||
} catch (e) {
|
||||
Notify.create({
|
||||
type: 'negative',
|
||||
message: `Could not log in.`,
|
||||
message: e.response.data.result,
|
||||
progress: true,
|
||||
position: 'top',
|
||||
timeout: 1500
|
||||
|
||||
@ -14,8 +14,13 @@ export function setUser (state, user) {
|
||||
state.user = user
|
||||
}
|
||||
|
||||
export function setLoginStatus (state, status) {
|
||||
state.loginStatus = status
|
||||
}
|
||||
|
||||
export function logout (state) {
|
||||
state.user = null
|
||||
state.loginStatus = null
|
||||
}
|
||||
|
||||
export function users (state, data) {
|
||||
|
||||
@ -2,6 +2,7 @@ export default function () {
|
||||
return {
|
||||
status: null,
|
||||
user: null,
|
||||
loginStatus: null,
|
||||
setup: {
|
||||
step: 1
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user