Skip to content
Extraits de code Groupes Projets
Valider 3f2ca2cd rédigé par DavePk04's avatar DavePk04
Parcourir les fichiers

fix: resolve code style issues for linting

parent 6f8718fb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -14,4 +14,4 @@ export const load: ServerLoad = async ({ locals, url }) => { ...@@ -14,4 +14,4 @@ export const load: ServerLoad = async ({ locals, url }) => {
if (user == null || user == undefined || user.type > 1) { if (user == null || user == undefined || user.type > 1) {
error(403, 'Forbidden'); error(403, 'Forbidden');
} }
}; };
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import Timeslots from '$lib/components/users/timeslots.svelte'; import Timeslots from '$lib/components/users/timeslots.svelte';
import User from '$lib/types/user'; import User from '$lib/types/user';
import { getUsersAPI, patchUserAPI, getUserContactsAPI, createUserAPI} from '$lib/api/users'; import { getUsersAPI, patchUserAPI, getUserContactsAPI, createUserAPI } from '$lib/api/users';
import { Icon, Envelope, Key, UserCircle, Calendar, QuestionMarkCircle } from 'svelte-hero-icons'; import { Icon, Envelope, Key, UserCircle, Calendar, QuestionMarkCircle } from 'svelte-hero-icons';
import Typingtest from '$lib/components/tests/typingtest.svelte'; import Typingtest from '$lib/components/tests/typingtest.svelte';
import { formatToUTCDate } from '$lib/utils/date'; import { formatToUTCDate } from '$lib/utils/date';
...@@ -54,57 +54,56 @@ ...@@ -54,57 +54,56 @@
let timeslots = 0n; let timeslots = 0n;
async function onRegister() { async function onRegister() {
// Basic validation // Basic validation
if (nickname == '' || email == '' || password == '' || confirmPassword == '') { if (nickname == '' || email == '' || password == '' || confirmPassword == '') {
message = $t('register.error.emptyFields'); message = $t('register.error.emptyFields');
return; return;
} }
if (password.length < 8) { if (password.length < 8) {
message = $t('register.error.passwordRules'); message = $t('register.error.passwordRules');
return; return;
} }
if (password != confirmPassword) { if (password != confirmPassword) {
message = $t('register.error.differentPasswords'); message = $t('register.error.differentPasswords');
return;
}
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (!emailRegex.test(email)) {
message = $t('register.error.emailRules');
return;
}
message = '';
try {
const response = await fetch('http://127.0.0.1:8000/tmp-api/v1/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
email,
password,
nickname,
is_tutor: true
})
});
if (response.status === 201) {
const userId = await response.text();
console.log('User created successfully with ID:', userId);
message = $t('register.success');
return; return;
} else { }
const errorData = await response.json(); const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
console.error('Registration failed:', errorData); if (!emailRegex.test(email)) {
message = errorData.detail || $t('register.error.generic'); message = $t('register.error.emailRules');
} return;
} catch (error) { }
console.error('Error during registration:', error); message = '';
message = $t('register.error.generic');
}
}
try {
const response = await fetch('http://127.0.0.1:8000/tmp-api/v1/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
email,
password,
nickname,
is_tutor: true
})
});
if (response.status === 201) {
const userId = await response.text();
console.log('User created successfully with ID:', userId);
message = $t('register.success');
return;
} else {
const errorData = await response.json();
console.error('Registration failed:', errorData);
message = errorData.detail || $t('register.error.generic');
}
} catch (error) {
console.error('Error during registration:', error);
message = $t('register.error.generic');
}
}
async function onData() { async function onData() {
const user_id = user.id; const user_id = user.id;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter