Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions components/SignInForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default function SignInForm({ routeAfterSignIn }) {
setPassword(e.target.value);
setErrorPassword("");
}}
onKeyDown={(e) => e.key === "Enter" && onSubmit()}
/>
<Field.ErrorText>{errorPassword}</Field.ErrorText>
</Field.Root>
Expand Down
29 changes: 21 additions & 8 deletions components/account/ChangePassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function ChangePassword() {
const [confirmPassword, setConfirmPassword] = useState("");
const [passwordMatch, setPasswordMatch] = useState(true);
const [passwordLengthSatisfied, setPasswordLengthSatisfied] = useState(true);
const [submitStatus, setSubmitStatus] = useState(null); // "success" | "failure" | null

useEffect(() => {
if (password !== confirmPassword) {
Expand All @@ -32,7 +33,7 @@ export default function ChangePassword() {
}, [password, confirmPassword]);

useEffect(() => {
if (password.length < 6) {
if (password.length < 12) {
setPasswordLengthSatisfied(false);
} else {
setPasswordLengthSatisfied(true);
Expand All @@ -42,9 +43,17 @@ export default function ChangePassword() {
return (
<HStack justifyContent="space-between" w="100%">
<Text fontSize={"lg"}>Password</Text>
<Button loading={isSubmitting} onClick={() => setOpen(true)} colorPalette="brandTeal">
Change Password
</Button>
<HStack>
{submitStatus === "success" && (
<Text fontSize="sm" color="green.400">Success</Text>
)}
{submitStatus === "failure" && (
<Text fontSize="sm" color="red.400">Failed</Text>
)}
<Button loading={isSubmitting} onClick={() => setOpen(true)} colorPalette="brandTeal">
Change Password
</Button>
</HStack>
<Dialog.Root open={open} onOpenChange={(e) => setOpen(e.open)}>
<Dialog.Backdrop />
<Dialog.Positioner>
Expand All @@ -64,7 +73,7 @@ export default function ChangePassword() {
onChange={(e) => setPassword(e.target.value)}
/>
<Field.ErrorText>
Password must be at least 6 characters
Password must be at least 12 characters
</Field.ErrorText>
</Field.Root>
<Field.Root id="confirm-password" invalid={!passwordMatch}>
Expand All @@ -83,8 +92,7 @@ export default function ChangePassword() {
variant={"solid"}
colorPalette={"brandTeal"}
size={"md"}
mr={4}
onClick={() => handleChangePassword(password, setIsSubmitting)}
onClick={() => handleChangePassword(password, setIsSubmitting, setOpen, setSubmitStatus)}
loading={isSubmitting}
disabled={!passwordMatch || !passwordLengthSatisfied}
>
Expand All @@ -98,14 +106,19 @@ export default function ChangePassword() {
);
}

async function handleChangePassword(newPassword, setIsSubmitting) {
async function handleChangePassword(newPassword, setIsSubmitting, setOpen, setSubmitStatus) {
setIsSubmitting(true);
const user = auth.currentUser;

try {
await updatePassword(user, newPassword);
setIsSubmitting(false);
setOpen(false);
setSubmitStatus("success");
} catch (error) {
console.log(error);
setIsSubmitting(false);
setOpen(false);
setSubmitStatus("failure");
}
}
1 change: 0 additions & 1 deletion components/account/SelectAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export default function SelectAuth() {
variant="solid"
colorPalette="brandTeal"
size="md"
mr={4}
onClick={handleSaveToken}
loading={isSubmittingToken}
>
Expand Down
1 change: 1 addition & 0 deletions pages/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default function SignUpPage() {
setPassword(e.target.value);
setErrorPassword("");
}}
onKeyDown={(e) => e.key === "Enter" && onSubmit()}
/>
<Field.HelperText display={errorPassword === "" ? "block" : "none"}>
Password must be at least 12 characters
Expand Down