-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: various fixes and enhancements (#2240)
* fix: 404 error on stream delete * fix: display error message for invalid payment card * api: add email verification check to /reset-token endpoint * ui: add 30 seconds time limit to password reset request * tests: fix /reset-password test * Update user.test.ts * feat: add sonner package as toaster * ui: add change password item to profile dropdown * ui: update toast position * revert: api changes related to password reset * run prettier * fix typo Co-authored-by: Chase Adams <[email protected]> * ui: replace toast with snackbar * ci: run prettier * Update index.tsx --------- Co-authored-by: Chase Adams <[email protected]>
- Loading branch information
1 parent
00bce20
commit ca62f7f
Showing
9 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Function to check if a user can request reset password or verfication email | ||
*/ | ||
|
||
export function canSendEmail(emailType: "resetPassword" | "verifyEmail"): { | ||
canSend: boolean; | ||
waitTime: number; | ||
} { | ||
const lastSentKey: string = `lastSent_${emailType}`; | ||
const lastSentTimestamp: string | null = localStorage.getItem(lastSentKey); | ||
|
||
if (lastSentTimestamp) { | ||
const currentTime: number = getCurrentTimestamp(); | ||
const timeDiff: number = currentTime - parseInt(lastSentTimestamp, 10); | ||
|
||
if (timeDiff < 30) { | ||
// If less than 30 seconds have passed, do not allow sending the email | ||
const waitTime: number = 30 - timeDiff; | ||
return { | ||
canSend: false, | ||
waitTime, | ||
}; | ||
} | ||
} | ||
|
||
const newSentKey: string = `lastSent_${emailType}`; | ||
localStorage.setItem(newSentKey, getCurrentTimestamp().toString()); | ||
return { | ||
canSend: true, | ||
waitTime: 0, | ||
}; | ||
} | ||
|
||
function getCurrentTimestamp(): number { | ||
return Math.floor(Date.now() / 1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters