|
@@ -24,7 +24,7 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
async execute(dto: AuthenticateUserDTO): Promise<AuthenticateUserResponse> {
|
|
|
const authenticationMethod = await this.authenticationMethodResolver.resolve(dto.token)
|
|
|
if (!authenticationMethod) {
|
|
|
- this.logger.debug('No authentication method found for token.')
|
|
|
+ this.logger.error(`[authenticate-user] No authentication method found for token: ${dto.token}`)
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -33,6 +33,8 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
}
|
|
|
|
|
|
if (authenticationMethod.type === 'revoked') {
|
|
|
+ this.logger.warn(`[authenticate-user] Session has been revoked: ${dto.token}`)
|
|
|
+
|
|
|
return {
|
|
|
success: false,
|
|
|
failureType: 'REVOKED_SESSION',
|
|
@@ -41,7 +43,7 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
|
|
|
const user = authenticationMethod.user
|
|
|
if (!user) {
|
|
|
- this.logger.debug('No user found for authentication method.')
|
|
|
+ this.logger.error(`[authenticate-user] No user found for authentication method. Token: ${dto.token}`)
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -50,7 +52,9 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
}
|
|
|
|
|
|
if (authenticationMethod.type == 'jwt' && user.supportsSessions()) {
|
|
|
- this.logger.debug('User supports sessions but is trying to authenticate with a JWT.')
|
|
|
+ this.logger.error(
|
|
|
+ `[authenticate-user][${user.uuid}] User supports sessions but is trying to authenticate with a JWT.`,
|
|
|
+ )
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -64,7 +68,7 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
const encryptedPasswordDigest = crypto.createHash('sha256').update(user.encryptedPassword).digest('hex')
|
|
|
|
|
|
if (!pwHash || !crypto.timingSafeEqual(Buffer.from(pwHash), Buffer.from(encryptedPasswordDigest))) {
|
|
|
- this.logger.debug('Password hash does not match.')
|
|
|
+ this.logger.error(`[authenticate-user][${user.uuid}] Password hash does not match.`)
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -76,7 +80,7 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
case 'session_token': {
|
|
|
const session = authenticationMethod.session
|
|
|
if (!session) {
|
|
|
- this.logger.debug('No session found for authentication method.')
|
|
|
+ this.logger.error(`[authenticate-user][${user.uuid}] No session found for authentication method.`)
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -85,7 +89,7 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
}
|
|
|
|
|
|
if (session.refreshExpiration < this.timer.getUTCDate()) {
|
|
|
- this.logger.debug('Session refresh token has expired.')
|
|
|
+ this.logger.warn(`[authenticate-user][${user.uuid}] Session refresh token has expired.`)
|
|
|
|
|
|
return {
|
|
|
success: false,
|
|
@@ -94,6 +98,8 @@ export class AuthenticateUser implements UseCaseInterface {
|
|
|
}
|
|
|
|
|
|
if (this.sessionIsExpired(session)) {
|
|
|
+ this.logger.warn(`[authenticate-user][${user.uuid}] Session access token has expired.`)
|
|
|
+
|
|
|
return {
|
|
|
success: false,
|
|
|
failureType: 'EXPIRED_TOKEN',
|