Skip to content

Commit

Permalink
fix: Improve pwd confirmation condition
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Dec 16, 2024
1 parent 6c4e40a commit eedfb45
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ let INTERCEPTOR_INITIALIZED = false
* @return {boolean} Whether password confirmation is required or was confirmed recently
*/
export const isPasswordConfirmationRequired = (mode: PwdConfirmationMode): boolean => {
if (!window.backendAllowsPasswordConfirmation) {
return false
}

if (mode === PwdConfirmationMode.Strict) {
return true
}

const serverTimeDiff = PAGE_LOAD_TIME - (window.nc_pageLoad * 1000)
const timeSinceLogin = Date.now() - (serverTimeDiff + (window.nc_lastLogin * 1000))

// If timeSinceLogin > 30 minutes and user backend allows password confirmation
return (window.backendAllowsPasswordConfirmation && timeSinceLogin > 30 * 60 * 1000)
// If timeSinceLogin > 30 minutes
return timeSinceLogin > 30 * 60 * 1000
}

/**
Expand Down

0 comments on commit eedfb45

Please sign in to comment.