-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: throw error when uid or password is missing
- Loading branch information
1 parent
d92068f
commit 8950749
Showing
2 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,4 +291,36 @@ test.group('withAuthFinder | verify', () => { | |
assert.isBelow(Math.abs(invalidPasswordTime.seconds - invalidEmailTime.seconds), 1) | ||
assert.isBelow(Math.abs(invalidPasswordTime.milliseconds - invalidEmailTime.milliseconds), 10) | ||
}) | ||
|
||
test('throw error when uid or password values are missing', async ({ assert }) => { | ||
const db = await createDatabase() | ||
await createTables(db) | ||
|
||
const hash = getHasher() | ||
|
||
class User extends compose( | ||
BaseModel, | ||
withAuthFinder(hash, { | ||
uids: ['email', 'username'], | ||
passwordColumnName: 'password', | ||
}) | ||
) { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare username: string | ||
|
||
@column() | ||
declare email: string | ||
|
||
@column() | ||
declare password: string | ||
} | ||
|
||
await assert.rejects( | ||
() => User.verifyCredentials('[email protected]', ''), | ||
'Invalid user credentials' | ||
) | ||
}) | ||
}) |