mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 05:49:25 +01:00
Merge pull request #1310 from slingamn/register_reviewfix
review fix for #1308
This commit is contained in:
commit
32f29aca52
@ -60,19 +60,18 @@ func parseCallback(spec string, config *Config) (callbackNamespace string, callb
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func registrationErrorToMessageAndCode(err error) (message, code string) {
|
func registrationErrorToMessage(err error) (message string) {
|
||||||
// default responses: let's be risk-averse about displaying internal errors
|
|
||||||
// to the clients, especially for something as sensitive as accounts
|
|
||||||
code = "REG_UNSPECIFIED_ERROR"
|
|
||||||
message = `Could not register`
|
|
||||||
switch err {
|
switch err {
|
||||||
case errAccountBadPassphrase:
|
case errAccountAlreadyRegistered, errAccountAlreadyVerified, errAccountAlreadyUnregistered, errAccountAlreadyLoggedIn, errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled, errAccountBadPassphrase:
|
||||||
code = "REG_INVALID_CREDENTIAL"
|
|
||||||
message = err.Error()
|
|
||||||
case errAccountAlreadyRegistered, errAccountAlreadyVerified, errAccountAlreadyUnregistered, errAccountAlreadyLoggedIn, errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled:
|
|
||||||
message = err.Error()
|
message = err.Error()
|
||||||
case errLimitExceeded:
|
case errLimitExceeded:
|
||||||
message = `There have been too many registration attempts recently; try again later`
|
message = `There have been too many registration attempts recently; try again later`
|
||||||
|
case errCallbackFailed:
|
||||||
|
message = `Could not dispatch verification email`
|
||||||
|
default:
|
||||||
|
// default response: let's be risk-averse about displaying internal errors
|
||||||
|
// to the clients, especially for something as sensitive as accounts
|
||||||
|
message = `Could not register`
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2460,7 +2459,6 @@ func registerHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *
|
|||||||
case errAccountBadPassphrase:
|
case errAccountBadPassphrase:
|
||||||
rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", client.t("Password was invalid"))
|
rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", client.t("Password was invalid"))
|
||||||
case errCallbackFailed:
|
case errCallbackFailed:
|
||||||
// TODO detect this in NS REGISTER as well
|
|
||||||
rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", client.t("Could not dispatch verification e-mail"))
|
rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", client.t("Could not dispatch verification e-mail"))
|
||||||
default:
|
default:
|
||||||
rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", client.t("Could not register"))
|
rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", client.t("Could not register"))
|
||||||
|
@ -873,7 +873,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// details could not be stored and relevant numerics have been dispatched, abort
|
// details could not be stored and relevant numerics have been dispatched, abort
|
||||||
message, _ := registrationErrorToMessageAndCode(err)
|
message := registrationErrorToMessage(err)
|
||||||
nsNotice(rb, client.t(message))
|
nsNotice(rb, client.t(message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user