From 67335130b1ec325ff766ceb87ccd7fa5256bc9d6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 1 Mar 2023 14:14:09 +0100 Subject: [PATCH] service: use database.User.SetPassword instead of bcrypt --- service.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/service.go b/service.go index 66f74fe..45e8e2c 100644 --- a/service.go +++ b/service.go @@ -15,7 +15,6 @@ import ( "time" "unicode" - "golang.org/x/crypto/bcrypt" "gopkg.in/irc.v4" "git.sr.ht/~emersion/soju/database" @@ -1032,12 +1031,11 @@ func handleUserUpdate(ctx *serviceContext, params []string) error { var hashed *string if password != nil { - hashedBytes, err := bcrypt.GenerateFromPassword([]byte(*password), bcrypt.DefaultCost) - if err != nil { - return fmt.Errorf("failed to hash password: %v", err) + var passwordRecord database.User + if err := passwordRecord.SetPassword(*password); err != nil { + return err } - hashedStr := string(hashedBytes) - hashed = &hashedStr + hashed = &passwordRecord.Password } if disablePassword { hashedStr := ""