check email + username availability

This commit is contained in:
tsmethurst 2021-03-25 23:34:00 +01:00
commit 88486b8447

View file

@ -26,7 +26,7 @@ import (
"github.com/gotosocial/gotosocial/pkg/mastotypes" "github.com/gotosocial/gotosocial/pkg/mastotypes"
) )
func validateCreateAccount(form *mastotypes.AccountCreateRequest, reasonRequired bool, db db.DB) error { func validateCreateAccount(form *mastotypes.AccountCreateRequest, reasonRequired bool, database db.DB) error {
if err := util.ValidateSignUpUsername(form.Username); err != nil { if err := util.ValidateSignUpUsername(form.Username); err != nil {
return err return err
} }
@ -51,7 +51,13 @@ func validateCreateAccount(form *mastotypes.AccountCreateRequest, reasonRequired
return err return err
} }
//TODO: validate new email address and new username if err := database.IsEmailAvailable(form.Email); err != nil {
return err
}
if err := database.IsUsernameAvailable(form.Username); err != nil {
return err
}
return nil return nil
} }