Login form will force username if there is an authenticated user

This commit is contained in:
garrettmills
2020-05-22 09:54:48 -05:00
parent decb83bdbb
commit 4f8c4d641f
5 changed files with 29 additions and 2 deletions

View File

@@ -75,6 +75,14 @@ export default class AuthLoginForm extends Component {
this.button_text = 'Next'
}
async vue_on_create() {
const auth_user = await auth_api.get_authenticated_user()
if ( auth_user ) {
this.username = auth_user
await this.step_click()
}
}
async on_key_up(event) {
if ( event.keyCode === 13 ) {
// Enter was pressed

View File

@@ -68,6 +68,12 @@ class AuthAPI {
if ( result && result.data && result.data.data ) return result.data.data
}
async get_authenticated_user() {
const result = await axios.get('/api/v1/auth/authenticated_user')
if ( result && result.data && result.data.data && result.data.data.authenticated )
return result.data.data.uid
}
async delete_app_password(uuid) {
await axios.delete(`/api/v1/password/app_passwords/${uuid}`)
}