Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(authorization) Wait 60 seconds before first otp resend request #181

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading