MCPcopy Create free account
hub / github.com/daodst/chat / validatePassword

Function validatePassword

clientapi/routing/register.go:317–331  ·  view source on GitHub ↗

validatePassword returns an error response if the password is invalid

(password string)

Source from the content-addressed store, hash-verified

315
316// validatePassword returns an error response if the password is invalid
317func 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
334func validateRecaptcha(

Callers 3

RegisterFunction · 0.85
PasswordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected