mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-05 16:56:22 +00:00
⚡ update environment mode handling, refactor user registration logic, and add username/email existence checks
This commit is contained in:
@ -43,3 +43,19 @@ func (user *userRepo) Update(userModel *model.User) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user *userRepo) CheckUsernameExists(username string) (bool, error) {
|
||||
var count int64
|
||||
if err := GetDB().Model(&model.User{}).Where("username = ?", username).Count(&count).Error; err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (user *userRepo) CheckEmailExists(email string) (bool, error) {
|
||||
var count int64
|
||||
if err := GetDB().Model(&model.User{}).Where("email = ?", email).Count(&count).Error; err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user