Add user credentials backup feature
This commit is contained in:
1 parent
db6a333029
commit
ef2667e71e
9 files changed
+261
-3
No files matched your search
@@ -127,6 +127,17 @@ func (r *Repository) UserByLogin(ctx context.Context, login string) (*User, erro
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (r *Repository) UserExistsByLogin(ctx context.Context, login string) (bool, error) {
|
||||
query := "SELECT EXISTS(SELECT 1 FROM users WHERE login = ?)"
|
||||
var exists bool
|
||||
err := r.q.QueryRowContext(ctx, query, login).Scan(&exists)
|
||||
if err != nil {
|
||||
slog.Error("user exists", slog.String("op", "repo.UserExistsByLogin"), slog.String("login", login), slog.Any("error", err))
|
||||
return false, ErrInternal
|
||||
}
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
func (r *Repository) UpdateUser(ctx context.Context, user *User) error {
|
||||
updatedAt := time.Now().UTC()
|
||||
query := "UPDATE users SET password = ?, fullname = ?, email = ?, is_admin = ?, updated_at = ?, activated_at = ? WHERE id = ?"
|
||||
|
||||
Reference in new issue
Block a user