Skip to content

Commit

Permalink
🐛 Redirect on register if not logged
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPLukaas committed May 17, 2024
1 parent bac0055 commit b736a00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion frontend-react/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const LoginPage = () => {
const [toastType, setToastType] = useState<'success' | 'error'>('success');
const [connectionError, setConnectionError] = useState<boolean>(false);

// Vérifiez la session dès que le composant est monté
useEffect(() => {
const checkSession = async () => {
const session = await verifySession();
Expand Down
12 changes: 11 additions & 1 deletion frontend-react/src/app/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// src/app/register/page.tsx

"use client";
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import RegisterForm from './form/RegisterForm';
import {useRouter} from 'next/navigation';
import Toast from "@/app/components/toasts";
import {register} from "@/app/register/services/registerService";
import {ApiResponse} from "@/app/api/apiService";
import {verifySession} from "@/app/lib/dal";

const RegisterPage = () => {
const router = useRouter();
Expand All @@ -15,6 +16,15 @@ const RegisterPage = () => {
const [toastMessage, setToastMessage] = useState<string>('');
const [toastType, setToastType] = useState<'success' | 'error'>('success');

useEffect(() => {
const checkSession = async () => {
const session = await verifySession();
if (session) {
router.push('/users');
}
};
checkSession().then(r => r);
}, [router]);

const handleRegister = async (user: {
email: string,
Expand Down

0 comments on commit b736a00

Please sign in to comment.