feat: automatic termination of older sessions on login (temporary until release 4);

fix: login controller method not returning tokens
This commit is contained in:
2025-07-06 14:45:36 +03:00
parent 8588a17928
commit 72a512bb4f
3 changed files with 23 additions and 8 deletions

View File

@@ -303,6 +303,15 @@ func (a *authServiceImpl) Login(request models.LoginRequest) (*models.LoginRespo
return nil, returnedError
}
// Until release 4, only 1 session at a time is supported
if err = db.TXQueries.TerminateAllSessionsForUserByUsername(db.CTX, request.Username); err != nil {
a.log.Error(
"Failed to terminate older sessions for user trying to log in",
zap.String("username", request.Username),
zap.Error(err))
return nil, errs.ErrServerError
}
session, err = db.TXQueries.CreateSession(db.CTX, database.CreateSessionParams{
// TODO: use actual values for session metadata
UserID: userRow.ID,