feat: add remember me style login #1339
|
@ -56,7 +56,8 @@
|
|||
"showPassword": "Show the password",
|
||||
"hidePassword": "Hide the password",
|
||||
"noAccountYet": "Don't have an account yet?",
|
||||
"alreadyHaveAnAccount": "Already have an account?"
|
||||
"alreadyHaveAnAccount": "Already have an account?",
|
||||
"remember": "Stay logged in"
|
||||
},
|
||||
"settings": {
|
||||
"title": "Settings",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {HTTPFactory} from '@/http-common'
|
||||
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
|
||||
import {objectToSnakeCase} from '@/helpers/case'
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
import {LOADING} from '../mutation-types'
|
||||
import UserModel from '@/models/user'
|
||||
import UserSettingsService from '@/services/userSettings'
|
||||
|
@ -90,17 +91,8 @@ export default {
|
|||
// Delete an eventually preexisting old token
|
||||
removeToken()
|
||||
|
||||
const data = {
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
}
|
||||
|
||||
if (credentials.totpPasscode) {
|
||||
data.totp_passcode = credentials.totpPasscode
|
||||
}
|
||||
|
||||
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
|
||||
konrad marked this conversation as resolved
Outdated
dpschen
commented
Why dont we simply convert credentials to snakecase for this object?
Why dont we simply convert credentials to snakecase for this object?
```js
async login(ctx, credentials) {
const HTTP = HTTPFactory()
ctx.commit(LOADING, true, {root: true})
// Delete an eventually preexisting old token
removeToken()
try {
const response = await HTTP.post('login', objectToSnakeCase(credentials))
```
konrad
commented
Very good point! I've changed it accordingly. Very good point! I've changed it accordingly.
|
||||
saveToken(response.data.token, true)
|
||||
|
||||
|
|
|
@ -58,6 +58,12 @@
|
|||
/>
|
||||
</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
|
||||
@click="submit"
|
||||
|
@ -118,6 +124,7 @@ export default {
|
|||
usernameValid: true,
|
||||
password: '',
|
||||
validatePasswordInitially: false,
|
||||
rememberMe: false,
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
|
@ -197,6 +204,7 @@ export default {
|
|||
const credentials = {
|
||||
username: this.$refs.username.value,
|
||||
password: this.password,
|
||||
longToken: this.rememberMe,
|
||||
}
|
||||
|
||||
if (credentials.username === '' || credentials.password === '') {
|
||||
|
|
Reference in New Issue
Use
@
Done!