feat: add remember me style login (#1339)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1339 Reviewed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de> Co-authored-by: konrad <k@knt.li> Co-committed-by: konrad <k@knt.li>
This commit is contained in:
parent
ba20ac3b89
commit
3d3ccf629a
3 changed files with 12 additions and 11 deletions
|
@ -56,7 +56,8 @@
|
||||||
"showPassword": "Show the password",
|
"showPassword": "Show the password",
|
||||||
"hidePassword": "Hide the password",
|
"hidePassword": "Hide the password",
|
||||||
"noAccountYet": "Don't have an account yet?",
|
"noAccountYet": "Don't have an account yet?",
|
||||||
"alreadyHaveAnAccount": "Already have an account?"
|
"alreadyHaveAnAccount": "Already have an account?",
|
||||||
|
"remember": "Stay logged in"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {HTTPFactory} from '@/http-common'
|
import {HTTPFactory} from '@/http-common'
|
||||||
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
|
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
|
||||||
|
import {objectToSnakeCase} from '@/helpers/case'
|
||||||
import {LOADING} from '../mutation-types'
|
import {LOADING} from '../mutation-types'
|
||||||
import UserModel from '@/models/user'
|
import UserModel from '@/models/user'
|
||||||
import UserSettingsService from '@/services/userSettings'
|
import UserSettingsService from '@/services/userSettings'
|
||||||
|
@ -90,17 +91,8 @@ export default {
|
||||||
// Delete an eventually preexisting old token
|
// Delete an eventually preexisting old token
|
||||||
removeToken()
|
removeToken()
|
||||||
|
|
||||||
const data = {
|
|
||||||
username: credentials.username,
|
|
||||||
password: credentials.password,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (credentials.totpPasscode) {
|
|
||||||
data.totp_passcode = credentials.totpPasscode
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await HTTP.post('login', data)
|
const response = await HTTP.post('login', objectToSnakeCase(credentials))
|
||||||
// Save the token to local storage for later use
|
// Save the token to local storage for later use
|
||||||
saveToken(response.data.token, true)
|
saveToken(response.data.token, true)
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,12 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">
|
||||||
|
<input type="checkbox" v-model="rememberMe" class="mr-1"/>
|
||||||
|
{{ $t('user.auth.remember') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<x-button
|
<x-button
|
||||||
@click="submit"
|
@click="submit"
|
||||||
|
@ -118,6 +124,7 @@ export default {
|
||||||
usernameValid: true,
|
usernameValid: true,
|
||||||
password: '',
|
password: '',
|
||||||
validatePasswordInitially: false,
|
validatePasswordInitially: false,
|
||||||
|
rememberMe: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
|
@ -197,6 +204,7 @@ export default {
|
||||||
const credentials = {
|
const credentials = {
|
||||||
username: this.$refs.username.value,
|
username: this.$refs.username.value,
|
||||||
password: this.password,
|
password: this.password,
|
||||||
|
longToken: this.rememberMe,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (credentials.username === '' || credentials.password === '') {
|
if (credentials.username === '' || credentials.password === '') {
|
||||||
|
|
Loading…
Reference in a new issue