From 3866b1bb441ec8c940aa644c4974cc05d470f866 Mon Sep 17 00:00:00 2001 From: mi1468 Date: Sat, 17 May 2025 12:54:12 +0330 Subject: [PATCH] added sms verification --- xroom-dashboard/src/api/axios.js | 3 + xroom-dashboard/src/pages/ResetPassword.vue | 2 +- xroom-dashboard/src/pages/SignupPage.vue | 4 +- xroom-dashboard/src/pages/SmsVerification.vue | 248 ++++++++++++++++++ xroom-dashboard/src/router/index.js | 17 +- 5 files changed, 268 insertions(+), 6 deletions(-) create mode 100644 xroom-dashboard/src/pages/SmsVerification.vue diff --git a/xroom-dashboard/src/api/axios.js b/xroom-dashboard/src/api/axios.js index e4d6ab3..c87162f 100644 --- a/xroom-dashboard/src/api/axios.js +++ b/xroom-dashboard/src/api/axios.js @@ -2,10 +2,13 @@ import axios from 'axios'; import { API_BASE_URL } from '@/config'; // Adjust the path if needed +const token = localStorage.getItem('token'); const apiClient = axios.create({ baseURL: API_BASE_URL, // All requests will prepend this URL headers: { 'Content-Type': 'application/json', + 'Authorization': `token ${token}`, + }, }); diff --git a/xroom-dashboard/src/pages/ResetPassword.vue b/xroom-dashboard/src/pages/ResetPassword.vue index c29c69d..2e1df2a 100644 --- a/xroom-dashboard/src/pages/ResetPassword.vue +++ b/xroom-dashboard/src/pages/ResetPassword.vue @@ -57,7 +57,7 @@ diff --git a/xroom-dashboard/src/pages/SignupPage.vue b/xroom-dashboard/src/pages/SignupPage.vue index ced589f..4d99e2f 100644 --- a/xroom-dashboard/src/pages/SignupPage.vue +++ b/xroom-dashboard/src/pages/SignupPage.vue @@ -45,7 +45,7 @@ @@ -80,7 +80,7 @@ export default { const response = await axios.post('http://194.62.43.230:8000/signup', signupData); console.log('Signup success:', response.data); // Redirect to login page upon successful signup - this.$router.push('/login'); + this.$router.push('/'); } catch (error) { console.error('Signup error:', error); // Handle error, show alert or error message diff --git a/xroom-dashboard/src/pages/SmsVerification.vue b/xroom-dashboard/src/pages/SmsVerification.vue new file mode 100644 index 0000000..a92a25e --- /dev/null +++ b/xroom-dashboard/src/pages/SmsVerification.vue @@ -0,0 +1,248 @@ + + + + + + diff --git a/xroom-dashboard/src/router/index.js b/xroom-dashboard/src/router/index.js index 611b82a..e3cec06 100644 --- a/xroom-dashboard/src/router/index.js +++ b/xroom-dashboard/src/router/index.js @@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router' import SignupPage from '../pages/SignupPage.vue' import LoginPage from '../pages/LoginPage.vue' import ResetPassword from '../pages/ResetPassword.vue' +import SmsVerification from '../pages/SmsVerification.vue' import DashboardPage from '../pages/dashboard/index.vue' import FilesPage from '@/pages/dashboard/files.vue'; import TeamsPage from '@/pages/dashboard/team.vue'; @@ -28,6 +29,11 @@ const routes = [ name: 'ResetPassword', component: ResetPassword }, + { + path: '/SmsVerification', + name: 'SmsVerification', + component: SmsVerification + }, { path: '/dashboard', name: 'DashboardPage', @@ -109,10 +115,15 @@ router.beforeEach(async (to, from, next) => { // Check if profile_glb is empty and not already going to ChangeAvatar const customer = response.data.customer || JSON.parse(localStorage.getItem('customer') || '{}'); - if (!customer.profile_glb && to.name !== 'ChangeAvatar') { - return next('/dashboard/ChangeAvatar'); + + if (!customer.is_sms_verified && to.name !== 'SmsVerification') { + return next('/SmsVerification'); } - + else if (!customer.profile_glb && to.name !== 'ReadyPlayer') { + return next('/dashboard/readyPlayer'); + } + + return next(); } catch (err) { // Invalid token, clear storage and redirect to login