forked from External/ergo
parent
dcfd8d8fe8
commit
46572b871f
5 changed files with 43 additions and 11 deletions
|
|
@ -15,6 +15,8 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/ergochat/irc-go/ircutils"
|
||||
|
||||
"github.com/ergochat/ergo/irc/connection_limits"
|
||||
"github.com/ergochat/ergo/irc/email"
|
||||
"github.com/ergochat/ergo/irc/migrations"
|
||||
|
|
@ -460,7 +462,7 @@ func (am *AccountManager) Register(client *Client, account string, callbackNames
|
|||
code, err := am.dispatchCallback(client, account, callbackNamespace, callbackValue)
|
||||
if err != nil {
|
||||
am.Unregister(casefoldedAccount, true)
|
||||
return errCallbackFailed
|
||||
return ®istrationCallbackError{underlying: err}
|
||||
} else {
|
||||
return am.server.store.Update(func(tx *buntdb.Tx) error {
|
||||
_, _, err = tx.Set(verificationCodeKey, code, setOptions)
|
||||
|
|
@ -469,6 +471,28 @@ func (am *AccountManager) Register(client *Client, account string, callbackNames
|
|||
}
|
||||
}
|
||||
|
||||
type registrationCallbackError struct {
|
||||
underlying error
|
||||
}
|
||||
|
||||
func (r *registrationCallbackError) Error() string {
|
||||
return `Account verification could not be sent`
|
||||
}
|
||||
|
||||
func registrationCallbackErrorText(config *Config, client *Client, err error) string {
|
||||
if callbackErr, ok := err.(*registrationCallbackError); ok {
|
||||
// only expose a user-visible error if we are doing direct sending
|
||||
if config.Accounts.Registration.EmailVerification.DirectSendingEnabled() {
|
||||
errorText := ircutils.SanitizeText(callbackErr.underlying.Error(), 350)
|
||||
return fmt.Sprintf(client.t("Could not dispatch registration e-mail: %s"), errorText)
|
||||
} else {
|
||||
return client.t("Could not dispatch registration e-mail")
|
||||
}
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// validatePassphrase checks whether a passphrase is allowed by our rules
|
||||
func validatePassphrase(passphrase string) error {
|
||||
// sanity check the length
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue