Skip to content

Commit

Permalink
Automatic sign-in after resetting password
Browse files Browse the repository at this point in the history
  • Loading branch information
Syu125 committed Apr 20, 2024
1 parent 45df318 commit cc4512e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/app/handlePasswordReset/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import React, { useState } from "react";
import Image from "next/image";
import styles from "@/app/handlePasswordReset/page.module.css";
import { verifyPasswordResetCode, confirmPasswordReset } from "firebase/auth";
import {
verifyPasswordResetCode,
confirmPasswordReset,
signInWithEmailAndPassword,
} from "firebase/auth";
import { initFirebase } from "@/firebase/firebase";
import { useRedirectToHomeIfSignedIn } from "@/hooks/useRedirection";
import { useEffect } from "react";
Expand Down Expand Up @@ -91,12 +95,11 @@ const PasswordReset: React.FC = () => {
if (actionCode != null) {
verifyPasswordResetCode(auth, actionCode)
.then((email) => {
const accountEmail = email;
if (actionCode != null) {
confirmPasswordReset(auth, actionCode, data.newPassword)
.then((resp) => {

Check warning on line 100 in frontend/src/app/handlePasswordReset/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

'resp' is defined but never used. Allowed unused args must match /^_/u
console.log("Password has been reset");
window.location.href = "/login";
signInWithEmailAndPassword(auth, email, data.newPassword);
})
.catch((error) => {
console.error("Confirm password reset failed: " + error);
Expand Down

0 comments on commit cc4512e

Please sign in to comment.