MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / SetPassword

Method SetPassword

internal/users/userrecord.go:580–594  ·  view source on GitHub ↗
(pw string)

Source from the content-addressed store, hash-verified

578}
579
580func (u *UserRecord) SetPassword(pw string) error {
581
582 validation := configs.GetValidationConfig()
583
584 if len(pw) < int(validation.PasswordSizeMin) || len(pw) > int(validation.PasswordSizeMax) {
585 return fmt.Errorf("password must be between %d and %d characters long", validation.PasswordSizeMin, validation.PasswordSizeMax)
586 }
587
588 hash, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost)
589 if err != nil {
590 return fmt.Errorf("failed to hash password: %w", err)
591 }
592 u.Password = string(hash)
593 return nil
594}
595
596func (u *UserRecord) ConnectionId() uint64 {
597 return u.connectionId

Callers 6

FinalizeLoginOrCreateFunction · 0.95
apiV1CreateUserFunction · 0.95
apiV1PatchUserFunction · 0.80
PasswordFunction · 0.80
mainFunction · 0.80

Calls 1

GetValidationConfigFunction · 0.92

Tested by 1