mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Refactor exception usage
This commit is contained in:
+4
-2
@@ -52,14 +52,16 @@ export interface ParentPassword {
|
||||
|
||||
export const assertParentPasswordValid = (password: ParentPassword) => {
|
||||
if (password.hash === '' || password.secondHash === '' || password.secondSalt === '') {
|
||||
throw new Error('missing fields at parent password')
|
||||
throw new ParentPasswordValidationException('missing fields at parent password')
|
||||
}
|
||||
|
||||
if (!(optionalPasswordRegex.test(password.hash) && optionalPasswordRegex.test(password.secondHash) && optionalSaltRegex.test(password.secondSalt))) {
|
||||
throw new Error('invalid parent password')
|
||||
throw new ParentPasswordValidationException('invalid parent password')
|
||||
}
|
||||
}
|
||||
|
||||
export class ParentPasswordValidationException extends Error {}
|
||||
|
||||
export interface CreateFamilyByMailTokenRequest {
|
||||
mailAuthToken: string
|
||||
parentPassword: ParentPassword
|
||||
|
||||
Reference in New Issue
Block a user