commit 5cd087241b841d14037424930e2dd498eca536b4
parent 832befd727a257581d774bb6bbdeb0f81cd658e2
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Tue, 11 Oct 2022 12:16:34 +0200
[bugfix] add in-use checks for admin cli account creation (#904)
Diffstat:
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/cmd/gotosocial/action/admin/account/account.go b/cmd/gotosocial/action/admin/account/account.go
@@ -46,6 +46,14 @@ var Create action.GTSAction = func(ctx context.Context) error {
return err
}
+ usernameAvailable, err := dbConn.IsUsernameAvailable(ctx, username)
+ if err != nil {
+ return err
+ }
+ if !usernameAvailable {
+ return fmt.Errorf("username %s is already in use", username)
+ }
+
email := config.GetAdminAccountEmail()
if email == "" {
return errors.New("no email set")
@@ -54,6 +62,14 @@ var Create action.GTSAction = func(ctx context.Context) error {
return err
}
+ emailAvailable, err := dbConn.IsEmailAvailable(ctx, email)
+ if err != nil {
+ return err
+ }
+ if !emailAvailable {
+ return fmt.Errorf("email address %s is already in use", email)
+ }
+
password := config.GetAdminAccountPassword()
if password == "" {
return errors.New("no password set")