|
|
@@ -116,6 +116,7 @@ const steps = ref(1); // 1 = credentials | 2 = code | 3 = user fields | 4 = cep
|
|
|
const clicked = ref(false);
|
|
|
const submitting = ref(false);
|
|
|
const loginForm = ref(null);
|
|
|
+const isLogin = ref(false);
|
|
|
|
|
|
const sendValidationCode = async () => {
|
|
|
const response = await sendCode(email.value, phone.value);
|
|
|
@@ -124,12 +125,18 @@ const sendValidationCode = async () => {
|
|
|
} else {
|
|
|
console.error('Failed to send validation code');
|
|
|
}
|
|
|
+ return response;
|
|
|
};
|
|
|
|
|
|
const validateCodeInput = async () => {
|
|
|
- const response = await validateCode(email.value, phone.value, code.value);
|
|
|
+ const response = await validateCode(email.value, phone.value, code.value, isLogin.value);
|
|
|
if (response.status === 200) {
|
|
|
- steps.value = 3;
|
|
|
+ if(isLogin.value == true) {
|
|
|
+ await setAuthDataFromPayload(response.data.payload);
|
|
|
+ router.push({ name: 'DashboardPage' });
|
|
|
+ } else {
|
|
|
+ steps.value = 3;
|
|
|
+ }
|
|
|
} else {
|
|
|
console.error('Invalid validation code');
|
|
|
}
|
|
|
@@ -156,7 +163,12 @@ const registerUserAndClient = async () => {
|
|
|
|
|
|
const onSubmit = async () => {
|
|
|
switch (steps.value) {
|
|
|
- case 1: await sendValidationCode(); break;
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ let response = await sendValidationCode();
|
|
|
+ isLogin.value = response.data.payload.isLogin;
|
|
|
+ break;
|
|
|
+ }
|
|
|
case 2: await validateCodeInput(); break;
|
|
|
case 3: await registerUserAndClient(); break;
|
|
|
default: break;
|