feat: align with upstream 1.5.9.9
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
interface InitialPasswordUserState {
|
||||
requirePasswordChange?: boolean | null
|
||||
}
|
||||
|
||||
interface StoredPasswordState {
|
||||
password?: string | null
|
||||
passwordChangedAt?: Date | string | null
|
||||
}
|
||||
|
||||
export interface PasswordSetupState {
|
||||
hasSetPassword: boolean
|
||||
needsInitialPasswordSetup: boolean
|
||||
}
|
||||
|
||||
export function getPasswordSetupState(
|
||||
storedPassword: StoredPasswordState,
|
||||
requirePasswordChange: boolean
|
||||
): PasswordSetupState {
|
||||
const hasSetPassword = !!storedPassword.password
|
||||
return {
|
||||
hasSetPassword,
|
||||
needsInitialPasswordSetup:
|
||||
!storedPassword.passwordChangedAt && (requirePasswordChange || !hasSetPassword)
|
||||
}
|
||||
}
|
||||
|
||||
export function canSetInitialPassword(
|
||||
user: InitialPasswordUserState,
|
||||
storedPassword: StoredPasswordState
|
||||
): boolean {
|
||||
return getPasswordSetupState(storedPassword, !!user.requirePasswordChange)
|
||||
.needsInitialPasswordSetup
|
||||
}
|
||||
Reference in New Issue
Block a user