Misc login form improvements

This commit is contained in:
garrettmills 2020-05-25 16:29:11 -05:00
parent 76ba843348
commit af01cd0f5d
No known key found for this signature in database
GPG Key ID: 6ACD58D6ADACFC6E
3 changed files with 14 additions and 10 deletions

View File

@ -1,3 +1,2 @@
- MFA recovery codes handling - MFA recovery codes handling
- OAuth2 -> support refresh tokens - OAuth2 -> support refresh tokens
- Traps -> not clearing trust?

View File

@ -45,7 +45,7 @@ const template = `
><a href="#" class="text-secondary" @click="on_register_click">Need an account?</a></small> ><a href="#" class="text-secondary" @click="on_register_click">Need an account?</a></small>
<small <small
class="mr-3" class="mr-3"
v-if="!loading" v-if="!auth_user && !loading"
><a href="#" class="text-secondary" @click="on_forgot_password">Forgot password?</a></small> ><a href="#" class="text-secondary" @click="on_forgot_password">Forgot password?</a></small>
<button type="button" class="btn btn-primary" :disabled="loading" v-if="step_two" v-on:click="back_click">Back</button> <button type="button" class="btn btn-primary" :disabled="loading" v-if="step_two" v-on:click="back_click">Back</button>
<button type="button" class="btn btn-primary" :disabled="loading || btn_disabled" v-on:click="step_click">{{ button_text }}</button> <button type="button" class="btn btn-primary" :disabled="loading || btn_disabled" v-on:click="step_click">{{ button_text }}</button>
@ -72,6 +72,7 @@ export default class AuthLoginForm extends Component {
error_message = '' error_message = ''
other_message = '' other_message = ''
allow_back = true allow_back = true
auth_user = false
watch_username(new_username, old_username) { watch_username(new_username, old_username) {
this.btn_disabled = !new_username this.btn_disabled = !new_username
@ -86,6 +87,7 @@ export default class AuthLoginForm extends Component {
async vue_on_create() { async vue_on_create() {
const auth_user = await auth_api.get_authenticated_user() const auth_user = await auth_api.get_authenticated_user()
if ( auth_user ) { if ( auth_user ) {
this.auth_user = true
this.allow_back = false this.allow_back = false
this.username = auth_user this.username = auth_user
await this.step_click() await this.step_click()

View File

@ -1,4 +1,5 @@
import { event_bus } from './EventBus.service.js' import { event_bus } from './EventBus.service.js'
import { auth_api } from './AuthApi.service.js'
class MessageService { class MessageService {
listener_interval = 25000 listener_interval = 25000
@ -20,7 +21,8 @@ class MessageService {
return axios.post(`/api/v1/message/banners/read/${banner_id}`) return axios.post(`/api/v1/message/banners/read/${banner_id}`)
} }
init_listener() { async init_listener() {
if ( await auth_api.get_authenticated_user() ) {
this.message_ids = [] this.message_ids = []
this.listener = setInterval(() => this._listener_tick(), this.listener_interval) this.listener = setInterval(() => this._listener_tick(), this.listener_interval)
window.addEventListener('beforeunload', () => this.stop_listener()) window.addEventListener('beforeunload', () => this.stop_listener())
@ -30,6 +32,7 @@ class MessageService {
this.stop_listener() this.stop_listener()
} }
} }
}
async _listener_tick() { async _listener_tick() {
const result = await this.fetch() const result = await this.fetch()