[O] Make login.ts code a lot shorter
This commit is contained in:
@@ -11,16 +11,16 @@ import VersionUtils from '@/logic/utils/version-utils';
|
|||||||
})
|
})
|
||||||
export default class Login extends Vue
|
export default class Login extends Vue
|
||||||
{
|
{
|
||||||
public username: string = '';
|
username = '';
|
||||||
public password: string = '';
|
password = '';
|
||||||
|
|
||||||
public loading: boolean = false;
|
loading = false;
|
||||||
public error: string = '';
|
error = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the instance is created.
|
* This is called when the instance is created.
|
||||||
*/
|
*/
|
||||||
public created()
|
created()
|
||||||
{
|
{
|
||||||
// Check login cookies
|
// Check login cookies
|
||||||
if (this.$cookies.isKey('va.token'))
|
if (this.$cookies.isKey('va.token'))
|
||||||
@@ -40,10 +40,7 @@ export default class Login extends Vue
|
|||||||
this.$emit('login:token', this.$cookies.get('va.token'));
|
this.$emit('login:token', this.$cookies.get('va.token'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else console.log('Cookies doesn\'t exist');
|
||||||
{
|
|
||||||
console.log('Cookies doesn\'t exist');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +48,7 @@ export default class Login extends Vue
|
|||||||
*
|
*
|
||||||
* @returns boolean Need to clear cookies or not
|
* @returns boolean Need to clear cookies or not
|
||||||
*/
|
*/
|
||||||
public needToUpdateCookies(): boolean
|
needToUpdateCookies(): boolean
|
||||||
{
|
{
|
||||||
// Version doesn't exist
|
// Version doesn't exist
|
||||||
if (!this.$cookies.isKey('va.version')) return true;
|
if (!this.$cookies.isKey('va.version')) return true;
|
||||||
@@ -63,7 +60,7 @@ export default class Login extends Vue
|
|||||||
/**
|
/**
|
||||||
* When the user clicks, send the username and password to the server.
|
* When the user clicks, send the username and password to the server.
|
||||||
*/
|
*/
|
||||||
public onLoginClick()
|
onLoginClick()
|
||||||
{
|
{
|
||||||
// Make login button loading
|
// Make login button loading
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -119,7 +116,7 @@ export default class Login extends Vue
|
|||||||
/**
|
/**
|
||||||
* This is called when the user hits enter on the input boxes.
|
* This is called when the user hits enter on the input boxes.
|
||||||
*/
|
*/
|
||||||
public onEnter()
|
onEnter()
|
||||||
{
|
{
|
||||||
this.onLoginClick();
|
this.onLoginClick();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user