MCPcopy Index your code
hub / github.com/coder/coder / validateUserPassword

Method validateUserPassword

coderd/userauth.go:470–492  ·  view source on GitHub ↗

ValidateUserPassword validates the complexity of a user password and that it is secured enough. @Summary Validate user password @ID validate-user-password @Security CoderSessionToken @Produce json @Accept json @Tags Authorization @Param request body codersdk.ValidateUserPasswordRequest true "Valida

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

468// @Success 200 {object} codersdk.ValidateUserPasswordResponse
469// @Router /api/v2/users/validate-password [post]
470func (*API) validateUserPassword(rw http.ResponseWriter, r *http.Request) {
471 var (
472 ctx = r.Context()
473 valid = true
474 details = ""
475 )
476
477 var req codersdk.ValidateUserPasswordRequest
478 if !httpapi.Read(ctx, rw, r, &req) {
479 return
480 }
481
482 err := userpassword.Validate(req.Password)
483 if err != nil {
484 valid = false
485 details = err.Error()
486 }
487
488 httpapi.Write(ctx, rw, http.StatusOK, codersdk.ValidateUserPasswordResponse{
489 Valid: valid,
490 Details: details,
491 })
492}
493
494// Authenticates the user with an email and password.
495//

Callers 1

PasswordFieldFunction · 0.80

Calls 5

ReadFunction · 0.92
ValidateFunction · 0.92
WriteFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected