Changeset 252 in code for trunk/service.go
- Timestamp:
- Apr 10, 2020, 8:16:25 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/service.go
r224 r252 8 8 9 9 "github.com/google/shlex" 10 "golang.org/x/crypto/bcrypt" 10 11 "gopkg.in/irc.v3" 11 12 ) … … 119 120 }, 120 121 }, 122 "change-password": { 123 usage: "<new password>", 124 desc: "change your password", 125 handle: handlePasswordChange, 126 }, 121 127 } 122 128 } … … 255 261 return nil 256 262 } 263 264 func handlePasswordChange(dc *downstreamConn, params []string) error { 265 if len(params) != 1 { 266 return fmt.Errorf("expected exactly one argument") 267 } 268 269 hashed, err := bcrypt.GenerateFromPassword([]byte(params[0]), bcrypt.DefaultCost) 270 if err != nil { 271 return fmt.Errorf("failed to hash password: %v", err) 272 } 273 if err := dc.user.updatePassword(string(hashed)); err != nil { 274 return err 275 } 276 277 sendServicePRIVMSG(dc, "password updated") 278 return nil 279 }
Note:
See TracChangeset
for help on using the changeset viewer.