register return error instead of bool

This commit is contained in:
Your Name 2024-03-01 09:40:12 -06:00
parent 0cb02fb65f
commit e9c29afd67
1 changed files with 2 additions and 2 deletions

View File

@ -94,7 +94,7 @@ func Register(username, email, ip string) error {
_, err = c.db.Query(fmt.Sprintf("insert into %s_users (username, password) VALUES (?,?)", c.TablePrefix), username, crypt) _, err = c.db.Query(fmt.Sprintf("insert into %s_users (username, password) VALUES (?,?)", c.TablePrefix), username, crypt)
if err != nil { if err != nil {
log.Printf("scsusers.Register: insert failed: %s\n", err.Error()) log.Printf("scsusers.Register: insert failed: %s\n", err.Error())
return fmt.Errorf("Failed to insert user") return fmt.Errorf("failed to insert user")
} }
if SendRegistrationEmail(email, username, string(pass)) { if SendRegistrationEmail(email, username, string(pass)) {
@ -107,7 +107,7 @@ func Register(username, email, ip string) error {
if err != nil { if err != nil {
log.Printf("scsusers.Register: Failed to delete new user %s: %s\n", username, err.Error()) log.Printf("scsusers.Register: Failed to delete new user %s: %s\n", username, err.Error())
} }
return fmt.Errorf("Failed to send registration email") return fmt.Errorf("failed to send registration email")
} }
func NewUser() *UserData { func NewUser() *UserData {