Skip to content

Commit

Permalink
Merge pull request #906 from nextcloud-libraries/artonge/fix/pwd_conf…
Browse files Browse the repository at this point in the history
…irmation_condition

fix: Improve pwd confirmation condition
  • Loading branch information
artonge authored Dec 16, 2024
2 parents 6c4e40a + eedfb45 commit dd9f4cd
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 dd9f4cd

Please sign in to comment.