Skip to content

Commit

Permalink
giong to test account confirmation again
Browse files Browse the repository at this point in the history
  • Loading branch information
adizafri2000 committed Jun 30, 2024
1 parent b945313 commit 584edc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ protected boolean shouldNotFilter(HttpServletRequest request) throws ServletExce
String path = request.getRequestURI();
if ( path.equals("/auth/login") ||
path.equals("/auth/signup") ||
path.equals("auth/refresh") ||
path.equals("auth/sendmail") ||
path.equals("auth/forgot-password") ||
path.equals("auth/reset-password") ||
path.equals("auth/resend-confirmation") ||
path.equals("/auth/refresh") ||
path.equals("/auth/sendmail") ||
path.equals("/auth/forgot-password") ||
path.equals("/auth/reset-password") ||
path.equals("/auth/resend-confirmation") ||
path.equals("/swagger-ui")
) {
return true;
Expand All @@ -41,7 +41,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
!path.equals("/auth/sendmail") &&
!path.equals("/swagger-ui") &&
!path.equals("/auth/forgot-password") &&
!path.equals("auth/resend-confirmation") &&
!path.equals("/auth/resend-confirmation") &&
!path.equals("/auth/reset-password")
){
String header = request.getHeader("Authorization");
Expand Down
18 changes: 14 additions & 4 deletions web/src/pages/ConfirmationPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { useNavigate, useLocation } from 'react-router-dom';
import authService from '../services/auth';
import CircularProgress from '@mui/material/CircularProgress';
import { toast } from 'react-toastify';
Expand All @@ -10,11 +10,19 @@ const ConfirmationPage = () => {
const [success, setSuccess] = useState(false);
const [showResendForm, setShowResendForm] = useState(false);
const [email, setEmail] = useState('');
const { token } = useParams();
const navigate = useNavigate();
const theme = useTheme();
const location = useLocation();

useEffect(() => {
const query = new URLSearchParams(location.search);
const token = query.get('token');

if (!token) {
toast.error('Invalid confirmation link.');
return;
}

const confirmAccount = async (token) => {
try {
setIsLoading(true);
Expand All @@ -24,14 +32,15 @@ const ConfirmationPage = () => {
navigate('/login');
} catch (error) {
console.error('Failed to confirm account:', error);
toast.error('Failed to confirm account: ', error);
toast.error(`Failed to confirm account: ${error}`);
setSuccess(false);
} finally {
setIsLoading(false);
}
};

confirmAccount(token);
}, [token, navigate]);
}, [location, navigate]);

const handleResendEmail = () => {
setShowResendForm(true);
Expand All @@ -41,6 +50,7 @@ const ConfirmationPage = () => {
try {
setIsLoading(true);
const data = { email };
console.log('resend confirm email data: ', data)
await authService.resendConfirmationEmail(data);
toast.success('Confirmation email sent, please check your email.');
setShowResendForm(false);
Expand Down

0 comments on commit 584edc6

Please sign in to comment.