adonisjs/auth

OAT Verify current time against expiresAt field for authentication

416c616e opened this issue · 1 comments

public async authenticate(): Promise<any> {

Would be handy to also check the expiresAt field against the current time to ensure the token hasn't expired.

Resolved it myself, I'm a big dumb dumb. On another note with it working correctly it would perhaps be nice to have the ability to assign a callback to optionally prune the token storage/db

Its already validated.

if (expiresAt instanceof Date) {
normalizedExpiryDate = DateTime.fromJSDate(expiresAt)
} else if (expiresAt && typeof expiresAt === 'string') {
normalizedExpiryDate = DateTime.fromFormat(expiresAt, client.dialect.dateTimeFormat)
} else if (expiresAt && typeof expiresAt === 'number') {
normalizedExpiryDate = DateTime.fromMillis(expiresAt)
}