diff --git a/src/lib/userFunction.js b/src/lib/userFunction.js
index 8e102be..af58320 100644
--- a/src/lib/userFunction.js
+++ b/src/lib/userFunction.js
@@ -7,12 +7,13 @@ export async function UserCheck(){
})
if(!response.ok){
+ window.location.href = '/info'
return(response.status)
}
else{
const data = await response.json();
- return data
+ return
}
}
@@ -62,6 +63,27 @@ export async function checkMail(mail) {
}
}
+export async function VerificationEmail(Code){
+ const response = await fetch('http://localhost:8000/api/users/email_verification',{
+ method:'POST',
+ credentials:'include',
+ headers:{
+ 'Content-Type' : 'application/json'
+ },
+ body: JSON.stringify({
+ "user_code": Code
+ })
+ })
+
+ if(response.status === 200){
+ window.location.href = '/'
+ return ""
+ }
+ else if(response.status === 422){
+ return "Неправильный код"
+ }
+}
+
export async function handleRegister(username,password,email,date_of_birth){
const response = await fetch('http://localhost:8000/api/users/register',{
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index fe9b435..197fcab 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -3,14 +3,6 @@
import { onMount } from 'svelte';
import {UserCheck} from '$lib/userFunction.js';
-onMount(async () => {
- const userData = await UserCheck();
-
- let userId = userData.id;
- let chatId = 2;
- if(userId === undefined)
- window.location.href = '/login'
-})