feat: integrate AI candidate review and automatic publication
This commit is contained in:
@@ -99,6 +99,14 @@ func (r *IdentityRepository) ListUsers(ctx context.Context, limit int) ([]model.
|
||||
}
|
||||
|
||||
func (r *IdentityRepository) ChangeAdminCredential(ctx context.Context, previousLogin, login, passwordHash string, now time.Time) (string, error) {
|
||||
return r.changeCredential(ctx, previousLogin, login, passwordHash, now, "ADMIN", "ADMIN_CREDENTIAL_CHANGED")
|
||||
}
|
||||
|
||||
func (r *IdentityRepository) ChangeDevelopmentUserCredential(ctx context.Context, previousLogin, login, passwordHash string, now time.Time) (string, error) {
|
||||
return r.changeCredential(ctx, previousLogin, login, passwordHash, now, "USER", "DEVELOPMENT_USER_CREDENTIAL_CHANGED")
|
||||
}
|
||||
|
||||
func (r *IdentityRepository) changeCredential(ctx context.Context, previousLogin, login, passwordHash string, now time.Time, expectedRole, action string) (string, error) {
|
||||
tx, err := r.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return "", mapError(err)
|
||||
@@ -109,7 +117,7 @@ func (r *IdentityRepository) ChangeAdminCredential(ctx context.Context, previous
|
||||
if err != nil {
|
||||
return "", mapError(err)
|
||||
}
|
||||
if role != "ADMIN" || status != "ACTIVE" {
|
||||
if role != expectedRole || status != "ACTIVE" {
|
||||
return "", apperror.ErrForbidden
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `UPDATE veyra_credential SET login_name=$2,password_hash=$3 WHERE user_id=$1`, userID, login, passwordHash); err != nil {
|
||||
@@ -119,7 +127,7 @@ func (r *IdentityRepository) ChangeAdminCredential(ctx context.Context, previous
|
||||
if err != nil {
|
||||
return "", mapError(err)
|
||||
}
|
||||
if err := appendAudit(ctx, tx, userID, "ADMIN_CREDENTIAL_CHANGED", "user", userID, uuid.NewString(), map[string]any{"sessions_revoked": tag.RowsAffected()}); err != nil {
|
||||
if err := appendAudit(ctx, tx, userID, action, "user", userID, uuid.NewString(), map[string]any{"sessions_revoked": tag.RowsAffected()}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user