From 88486b8447b567ce74e1d756d28f829e3c65489b Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Thu, 25 Mar 2021 23:34:00 +0100 Subject: [PATCH] check email + username availability --- internal/module/account/validation.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/module/account/validation.go b/internal/module/account/validation.go index 3078b68..f2a0ac9 100644 --- a/internal/module/account/validation.go +++ b/internal/module/account/validation.go @@ -26,7 +26,7 @@ import ( "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 { return err } @@ -51,7 +51,13 @@ func validateCreateAccount(form *mastotypes.AccountCreateRequest, reasonRequired 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 }