mirror of
https://github.com/Dadechin/XRoomDashboardFront.git
synced 2025-07-05 01:34:34 +00:00
added sms verification
This commit is contained in:
parent
857fa68231
commit
3866b1bb44
|
@ -2,10 +2,13 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { API_BASE_URL } from '@/config'; // Adjust the path if needed
|
import { API_BASE_URL } from '@/config'; // Adjust the path if needed
|
||||||
|
|
||||||
|
const token = localStorage.getItem('token');
|
||||||
const apiClient = axios.create({
|
const apiClient = axios.create({
|
||||||
baseURL: API_BASE_URL, // All requests will prepend this URL
|
baseURL: API_BASE_URL, // All requests will prepend this URL
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `token ${token}`,
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<!-- Links -->
|
<!-- Links -->
|
||||||
<div class="login-link">
|
<div class="login-link">
|
||||||
<router-link to="/signup">ساخت حساب کاربری</router-link> |
|
<router-link to="/signup">ساخت حساب کاربری</router-link> |
|
||||||
<router-link to="/login">ورود</router-link>
|
<router-link to="/">ورود</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
<!-- Login Link -->
|
<!-- Login Link -->
|
||||||
<div class="login-link">
|
<div class="login-link">
|
||||||
<router-link to="/login">حساب کاربری دارید؟ وارد شوید</router-link>
|
<router-link to="/">حساب کاربری دارید؟ وارد شوید</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -80,7 +80,7 @@ export default {
|
||||||
const response = await axios.post('http://194.62.43.230:8000/signup', signupData);
|
const response = await axios.post('http://194.62.43.230:8000/signup', signupData);
|
||||||
console.log('Signup success:', response.data);
|
console.log('Signup success:', response.data);
|
||||||
// Redirect to login page upon successful signup
|
// Redirect to login page upon successful signup
|
||||||
this.$router.push('/login');
|
this.$router.push('/');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Signup error:', error);
|
console.error('Signup error:', error);
|
||||||
// Handle error, show alert or error message
|
// Handle error, show alert or error message
|
||||||
|
|
248
xroom-dashboard/src/pages/SmsVerification.vue
Normal file
248
xroom-dashboard/src/pages/SmsVerification.vue
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
<template>
|
||||||
|
<div class="signup-page">
|
||||||
|
<div class="signup-form">
|
||||||
|
<h2 class="title">
|
||||||
|
<img :src="require('@/assets/img/logo.png')" alt="Logo" style="max-width: 150px;" />
|
||||||
|
</h2>
|
||||||
|
<h3 class="subtitle"> تایید شماره موبایل </h3>
|
||||||
|
|
||||||
|
<h5 class="descript-xroom">
|
||||||
|
پیامکی شامل کد تایید به موبایل شما ارسال شده است.
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
<button type="submit" style="margin-bottom: 35px;" class="submit-btn" @click="sendSms">
|
||||||
|
ارسال مجدد کد
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Step 1: Mobile Number Input -->
|
||||||
|
<!-- <form v-if="!codeSent" @submit.prevent="requestResetCode">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="phone">شماره تماس</label>
|
||||||
|
<input
|
||||||
|
v-model="form.mobileNumber"
|
||||||
|
type="text"
|
||||||
|
id="phone"
|
||||||
|
placeholder="شماره تماس"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form> -->
|
||||||
|
|
||||||
|
<!-- Step 2: Code and New Password Input -->
|
||||||
|
<form @submit.prevent="submitSmsVerification">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">کد تأیید</label>
|
||||||
|
<input
|
||||||
|
v-model="form.code"
|
||||||
|
type="text"
|
||||||
|
id="code"
|
||||||
|
placeholder="کد تأیید دریافت شده"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<button type="submit" class="submit-btn">
|
||||||
|
تایید کد
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Links -->
|
||||||
|
<div class="login-link">
|
||||||
|
<router-link to="/signup">ساخت حساب کاربری</router-link>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import apiClient from '@/api/axios'; // Adjust the path based on your project structure
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
mobileNumber: '',
|
||||||
|
code: '',
|
||||||
|
password: '',
|
||||||
|
},
|
||||||
|
codeSent: false, // Tracks if the code has been sent
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async sendSms() {
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem('token');
|
||||||
|
|
||||||
|
const response = await apiClient.get('/sendSmsVerification', {
|
||||||
|
// mobile_number: this.form.mobileNumber,
|
||||||
|
}, {
|
||||||
|
'Authorization': `Token ${token}`,
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
});
|
||||||
|
// const response = await axios.post(uploadUrl, formData, {
|
||||||
|
// headers: {
|
||||||
|
// 'Authorization': `Token ${token}`,
|
||||||
|
// 'Content-Type': 'multipart/form-data'
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
if (response.data.success) {
|
||||||
|
this.codeSent = true;
|
||||||
|
alert('کد تأیید به شماره موبایل شما ارسال شد.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error requesting reset code:', error);
|
||||||
|
alert('خطا در ارسال کد تأیید. لطفاً دوباره تلاش کنید.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async submitSmsVerification() {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.post('/submitSmsVerification', {
|
||||||
|
|
||||||
|
verification_sms_code: this.form.code,
|
||||||
|
|
||||||
|
});
|
||||||
|
if (response.status == 200) {
|
||||||
|
alert('رمز عبور با موفقیت بازنشانی شد.');
|
||||||
|
this.$router.push('/dashboard');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error resetting password:', error);
|
||||||
|
alert('خطا در بازنشانی رمز عبور. لطفاً کد یا رمز عبور را بررسی کنید.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.descript-xroom {
|
||||||
|
font-family: IRANSansXFaNum;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 210%;
|
||||||
|
letter-spacing: 0%;
|
||||||
|
text-align: justify;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
/* Basic reset */
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Body and Background Styling */
|
||||||
|
.signup-page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-image: url('@/assets/background.jpg'); /* Correct path */
|
||||||
|
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-form {
|
||||||
|
direction: rtl;
|
||||||
|
background-color: rgba(255, 255, 255, 1); /* Semi-transparent white background */
|
||||||
|
padding: 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||||
|
width: 100%;
|
||||||
|
max-width: 682px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 36px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #4A90E2;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 24px;
|
||||||
|
color: #444;
|
||||||
|
text-align: right;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
margin-top: 66px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #555;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
font-size: 16px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input:focus {
|
||||||
|
border-color: #4A90E2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terms-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terms-checkbox input {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: #4A90E2;
|
||||||
|
color: white;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn:disabled {
|
||||||
|
background-color: #ccc;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn:hover:enabled {
|
||||||
|
background-color: #357ABD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-link {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-link a {
|
||||||
|
color: #4A90E2;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-link a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import SignupPage from '../pages/SignupPage.vue'
|
import SignupPage from '../pages/SignupPage.vue'
|
||||||
import LoginPage from '../pages/LoginPage.vue'
|
import LoginPage from '../pages/LoginPage.vue'
|
||||||
import ResetPassword from '../pages/ResetPassword.vue'
|
import ResetPassword from '../pages/ResetPassword.vue'
|
||||||
|
import SmsVerification from '../pages/SmsVerification.vue'
|
||||||
import DashboardPage from '../pages/dashboard/index.vue'
|
import DashboardPage from '../pages/dashboard/index.vue'
|
||||||
import FilesPage from '@/pages/dashboard/files.vue';
|
import FilesPage from '@/pages/dashboard/files.vue';
|
||||||
import TeamsPage from '@/pages/dashboard/team.vue';
|
import TeamsPage from '@/pages/dashboard/team.vue';
|
||||||
|
@ -28,6 +29,11 @@ const routes = [
|
||||||
name: 'ResetPassword',
|
name: 'ResetPassword',
|
||||||
component: ResetPassword
|
component: ResetPassword
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/SmsVerification',
|
||||||
|
name: 'SmsVerification',
|
||||||
|
component: SmsVerification
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/dashboard',
|
path: '/dashboard',
|
||||||
name: 'DashboardPage',
|
name: 'DashboardPage',
|
||||||
|
@ -109,9 +115,14 @@ router.beforeEach(async (to, from, next) => {
|
||||||
|
|
||||||
// Check if profile_glb is empty and not already going to ChangeAvatar
|
// Check if profile_glb is empty and not already going to ChangeAvatar
|
||||||
const customer = response.data.customer || JSON.parse(localStorage.getItem('customer') || '{}');
|
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();
|
return next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user