[O] Encapsulate login()

This commit is contained in:
Hykilpikonna
2019-12-02 13:55:58 -05:00
parent 7550a99166
commit e99e6170b8
+13 -1
View File
@@ -71,8 +71,20 @@ export default class Login extends Vue
// Format it
this.username = this.username.toLowerCase().replace(/ /g, '').replace(/@.*/g, '');
// Login
this.login('/login', {username: this.username, password: this.password});
}
/**
* Actually post the login request and process the response
*
* @param url Posting url
* @param data Data to be posted
*/
login(url: string, data: any)
{
// Fetch request
App.http.post('/login', {username: this.username, password: this.password})
App.http.post(url, data)
.then(response =>
{
// Check success