Browse Source

make `ergo genpasswd` warn for bad passwords

tags/v2.8.0-rc1
Shivaram Lingamneni 2 years ago
parent
commit
7d5cb723b4
2 changed files with 8 additions and 4 deletions
  1. 4
    0
      ergo.go
  2. 4
    4
      irc/accounts.go

+ 4
- 0
ergo.go View File

@@ -128,6 +128,10 @@ Options:
128 128
 		} else {
129 129
 			password = getPassword()
130 130
 		}
131
+		if err := irc.ValidatePassphrase(password); err != nil {
132
+			log.Printf("WARNING: this password contains characters that may cause problems with your IRC client software.\n")
133
+			log.Printf("We strongly recommend choosing a different password.\n")
134
+		}
131 135
 		hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost)
132 136
 		if err != nil {
133 137
 			log.Fatal("encoding error:", err.Error())

+ 4
- 4
irc/accounts.go View File

@@ -503,8 +503,8 @@ func registrationCallbackErrorText(config *Config, client *Client, err error) st
503 503
 	}
504 504
 }
505 505
 
506
-// validatePassphrase checks whether a passphrase is allowed by our rules
507
-func validatePassphrase(passphrase string) error {
506
+// ValidatePassphrase checks whether a passphrase is allowed by our rules
507
+func ValidatePassphrase(passphrase string) error {
508 508
 	// sanity check the length
509 509
 	if len(passphrase) == 0 || len(passphrase) > 300 {
510 510
 		return errAccountBadPassphrase
@@ -1122,7 +1122,7 @@ func (am *AccountManager) NsSendpass(client *Client, accountName string) (err er
1122 1122
 }
1123 1123
 
1124 1124
 func (am *AccountManager) NsResetpass(client *Client, accountName, code, password string) (err error) {
1125
-	if validatePassphrase(password) != nil {
1125
+	if ValidatePassphrase(password) != nil {
1126 1126
 		return errAccountBadPassphrase
1127 1127
 	}
1128 1128
 	account, err := am.LoadAccount(accountName)
@@ -2181,7 +2181,7 @@ func (ac *AccountCredentials) SetPassphrase(passphrase string, bcryptCost uint)
2181 2181
 		return nil
2182 2182
 	}
2183 2183
 
2184
-	if validatePassphrase(passphrase) != nil {
2184
+	if ValidatePassphrase(passphrase) != nil {
2185 2185
 		return errAccountBadPassphrase
2186 2186
 	}
2187 2187
 

Loading…
Cancel
Save