Skip to content

Commit

Permalink
fix(authorization) Wait 60 seconds before first otp resend request (#181
Browse files Browse the repository at this point in the history
)

Co-authored-by: Aleksey Svetlitskiy <a.svetlitskiy@gmail.com>
  • Loading branch information
aleksey-svetliskiy-cere and svetlitskiy authored Mar 5, 2024
1 parent 6d7cd6a commit 9a3b1a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Login/OtpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { reportError } from '~/reporting';
import { AuthApiService } from '~/api/auth-api.service';
import { CereWhiteLogo } from '~/components';

const TIME_LEFT = 60; // seconds before next otp request

interface OtpProps {
email?: string;
onRequestLogin: (idToken: string) => void | Promise<void>;
Expand All @@ -33,7 +35,7 @@ const validationSchema = yup
export const OtpPage = ({ email, onRequestLogin }: OtpProps) => {
const location = useLocation();
const navigate = useNavigate();
const [timeLeft, setTimeLeft] = useState<number>(0);
const [timeLeft, setTimeLeft] = useState<number>(TIME_LEFT);
const { isGame } = useTheme();

const {
Expand Down Expand Up @@ -71,7 +73,7 @@ export const OtpPage = ({ email, onRequestLogin }: OtpProps) => {
};

const handleResend = async () => {
setTimeLeft(60);
setTimeLeft(TIME_LEFT);
await AuthApiService.sendOtp(email!);
};

Expand Down

0 comments on commit 9a3b1a7

Please sign in to comment.