From d267988b55090ad4b2c88aa62c589eb4e5fa53c8 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 25 May 2020 21:11:27 -0400 Subject: [PATCH] [O] Combine login into one function --- src/components/login/login.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 52b85b8..2817f70 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -58,8 +58,18 @@ export default class Login extends Vue /** * When the user clicks, send the username and password to the server. + * This is also called when the user hits enter on the input boxes. */ onLoginClick() + { + this.login() + } + + + /** + * Actually post the login request and process the response + */ + login() { // Make login button loading this.loading = true; @@ -67,21 +77,8 @@ 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(url, data) - .then(response => + App.http.post('/login', {username: this.username, password: this.password}).then(response => { // Check success if (response.success)