From a5b78afaca06f8876b9625a5d45f14709d0e3fc3 Mon Sep 17 00:00:00 2001 From: Alessio Comi Date: Fri, 5 Apr 2024 15:17:22 +0200 Subject: [PATCH 1/2] my bad --- frontend/src/views/Authentication/LogoutView.vue | 3 +++ frontend/src/views/Authentication/SignUpView.vue | 3 +++ 2 files changed, 6 insertions(+) diff --git a/frontend/src/views/Authentication/LogoutView.vue b/frontend/src/views/Authentication/LogoutView.vue index e69de29..956dc09 100644 --- a/frontend/src/views/Authentication/LogoutView.vue +++ b/frontend/src/views/Authentication/LogoutView.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/frontend/src/views/Authentication/SignUpView.vue b/frontend/src/views/Authentication/SignUpView.vue index e69de29..08d003c 100644 --- a/frontend/src/views/Authentication/SignUpView.vue +++ b/frontend/src/views/Authentication/SignUpView.vue @@ -0,0 +1,3 @@ + \ No newline at end of file From cf1d12136ad4bb694ff396c4725bbe10bb778eca Mon Sep 17 00:00:00 2001 From: Alessio Comi Date: Sat, 13 Apr 2024 21:14:58 +0200 Subject: [PATCH 2/2] basic view for login page and signup page --- frontend/src/api_client.js | 38 +++++++++- frontend/src/components/Header.vue | 2 + .../src/views/Authentication/LoginView.vue | 71 +++++++++++++------ .../src/views/Authentication/SignUpView.vue | 63 +++++++++++++++- 4 files changed, 149 insertions(+), 25 deletions(-) diff --git a/frontend/src/api_client.js b/frontend/src/api_client.js index 76e914a..47262ec 100644 --- a/frontend/src/api_client.js +++ b/frontend/src/api_client.js @@ -145,4 +145,40 @@ export default }); return response.data; } -} \ No newline at end of file + + /** + * Register a new user + * @param {String} username The username of the new user + * @param {String} password The password of the new user + * @returns {Object} The response data from the API + */ + static async registerUser(username, password) { + try { + const response = await axios.post('/api/user/signup/', { + username, + password + }); + return response.data; + } catch (error) { + throw new Error('Error registering user: ' + error.message); + } + } + + /** + * Log in an existing user + * @param {String} username The username of the user + * @param {String} password The password of the user + * @returns {Object} The response data from the API + */ + static async loginUser(username, password) { + try { + const response = await axios.post('/api/user/login/', { + username, + password + }); + return response.data; + } catch (error) { + throw new Error('Error logging in: ' + error.message); + } + } +} diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue index b8a4850..03628e0 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -10,6 +10,8 @@ import { RouterLink } from 'vue-router' Categories Add question Login + Logout + SignUp diff --git a/frontend/src/views/Authentication/LoginView.vue b/frontend/src/views/Authentication/LoginView.vue index e88b3b6..52e8ff7 100644 --- a/frontend/src/views/Authentication/LoginView.vue +++ b/frontend/src/views/Authentication/LoginView.vue @@ -1,32 +1,59 @@ + \ No newline at end of file +
+ +
+ + + diff --git a/frontend/src/views/Authentication/SignUpView.vue b/frontend/src/views/Authentication/SignUpView.vue index 08d003c..786fad0 100644 --- a/frontend/src/views/Authentication/SignUpView.vue +++ b/frontend/src/views/Authentication/SignUpView.vue @@ -1,3 +1,62 @@ + + \ No newline at end of file +
+
+

Register

+

{{ validationMessage }}

+
+ + + +
+ +
+ +
+
+ + + +