validatePassword returns an error response if the password is invalid
(password string)
| 315 | |
| 316 | // validatePassword returns an error response if the password is invalid |
| 317 | func validatePassword(password string) *util.JSONResponse { |
| 318 | // https://github.com/matrix-org/synapse/blob/v0.20.0/synapse/rest/client/v2_alpha/register.py#L161 |
| 319 | if len(password) > maxPasswordLength { |
| 320 | return &util.JSONResponse{ |
| 321 | Code: http.StatusBadRequest, |
| 322 | JSON: jsonerror.BadJSON(fmt.Sprintf("'password' >%d characters", maxPasswordLength)), |
| 323 | } |
| 324 | } else if len(password) > 0 && len(password) < minPasswordLength { |
| 325 | return &util.JSONResponse{ |
| 326 | Code: http.StatusBadRequest, |
| 327 | JSON: jsonerror.WeakPassword(fmt.Sprintf("password too weak: min %d chars", minPasswordLength)), |
| 328 | } |
| 329 | } |
| 330 | return nil |
| 331 | } |
| 332 | |
| 333 | // validateRecaptcha returns an error response if the captcha response is invalid |
| 334 | func validateRecaptcha( |
no outgoing calls
no test coverage detected