fix: improve password validation flow (#15132)

Refers to #14984 

Currently, password validation is done backend side and is not explicit
enough so it can be painful to create first users.
We'd like to make this validation easier - but also duplicate it
frontend side to make it smoother.

Flows involved : 
- First user set password
- New user set password
- Change password

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
This commit is contained in:
Vincent Vielle
2024-11-05 17:22:32 +01:00
committed by GitHub
parent 8b5a18cade
commit 4fe2c5f09a
21 changed files with 530 additions and 74 deletions

61
coderd/apidoc/docs.go generated
View File

@ -5373,6 +5373,45 @@ const docTemplate = `{
}
}
},
"/users/validate-password": {
"post": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Authorization"
],
"summary": "Validate user password",
"operationId": "validate-user-password",
"parameters": [
{
"description": "Validate user password request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.ValidateUserPasswordRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.ValidateUserPasswordResponse"
}
}
}
}
},
"/users/{user}": {
"get": {
"security": [
@ -14096,6 +14135,28 @@ const docTemplate = `{
"UserStatusSuspended"
]
},
"codersdk.ValidateUserPasswordRequest": {
"type": "object",
"required": [
"password"
],
"properties": {
"password": {
"type": "string"
}
}
},
"codersdk.ValidateUserPasswordResponse": {
"type": "object",
"properties": {
"details": {
"type": "string"
},
"valid": {
"type": "boolean"
}
}
},
"codersdk.ValidationError": {
"type": "object",
"required": [