|
@@ -121,6 +121,18 @@ or other verification.`,
|
121
|
121
|
helpShort: `$bVERIFY$b lets you complete account registration.`,
|
122
|
122
|
enabled: servCmdRequiresAccreg,
|
123
|
123
|
},
|
|
124
|
+ "passwd": {
|
|
125
|
+ handler: nsPasswdHandler,
|
|
126
|
+ help: `Syntax: $bPASSWD <current> <new> <new_again>$b
|
|
127
|
+Or: $bPASSWD <username> <new>$b
|
|
128
|
+
|
|
129
|
+PASSWD lets you change your account password. You must supply your current
|
|
130
|
+password and confirm the new one by typing it twice. If you're an IRC operator
|
|
131
|
+with the correct permissions, you can use PASSWD to reset someone else's
|
|
132
|
+password by supplying their username and then the desired password.`,
|
|
133
|
+ helpShort: `$bPASSWD$b lets you change your password.`,
|
|
134
|
+ enabled: servCmdRequiresAuthEnabled,
|
|
135
|
+ },
|
124
|
136
|
}
|
125
|
137
|
)
|
126
|
138
|
|
|
@@ -389,3 +401,49 @@ func nsVerifyHandler(server *Server, client *Client, command, params string, rb
|
389
|
401
|
|
390
|
402
|
sendSuccessfulRegResponse(client, rb, true)
|
391
|
403
|
}
|
|
404
|
+
|
|
405
|
+func nsPasswdHandler(server *Server, client *Client, command, params string, rb *ResponseBuffer) {
|
|
406
|
+ var target string
|
|
407
|
+ var newPassword string
|
|
408
|
+ var errorMessage string
|
|
409
|
+
|
|
410
|
+ fields := strings.Fields(params)
|
|
411
|
+ switch len(fields) {
|
|
412
|
+ case 2:
|
|
413
|
+ if !client.HasRoleCapabs("accreg") {
|
|
414
|
+ errorMessage = "Insufficient privileges"
|
|
415
|
+ } else {
|
|
416
|
+ target, newPassword = fields[0], fields[1]
|
|
417
|
+ }
|
|
418
|
+ case 3:
|
|
419
|
+ target = client.Account()
|
|
420
|
+ if target == "" {
|
|
421
|
+ errorMessage = "You're not logged into an account"
|
|
422
|
+ } else if fields[1] != fields[2] {
|
|
423
|
+ errorMessage = "Passwords do not match"
|
|
424
|
+ } else {
|
|
425
|
+ // check that they correctly supplied the preexisting password
|
|
426
|
+ _, err := server.accounts.checkPassphrase(target, fields[0])
|
|
427
|
+ if err != nil {
|
|
428
|
+ errorMessage = "Password incorrect"
|
|
429
|
+ } else {
|
|
430
|
+ newPassword = fields[1]
|
|
431
|
+ }
|
|
432
|
+ }
|
|
433
|
+ default:
|
|
434
|
+ errorMessage = "Invalid parameters"
|
|
435
|
+ }
|
|
436
|
+
|
|
437
|
+ if errorMessage != "" {
|
|
438
|
+ nsNotice(rb, client.t(errorMessage))
|
|
439
|
+ return
|
|
440
|
+ }
|
|
441
|
+
|
|
442
|
+ err := server.accounts.setPassword(target, newPassword)
|
|
443
|
+ if err == nil {
|
|
444
|
+ nsNotice(rb, client.t("Password changed"))
|
|
445
|
+ } else {
|
|
446
|
+ server.logger.Error("internal", fmt.Sprintf("could not upgrade user password: %v", err))
|
|
447
|
+ nsNotice(rb, client.t("Password could not be changed due to server error"))
|
|
448
|
+ }
|
|
449
|
+}
|