Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): add user profile and password changing #966

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preLaunchTask": "Build for debugging",
"env": {
"ATK_SITE_DEFAULT": "ArtalkDocs",
"ATK_TRUSTED_DOMAINS": "http://localhost:5173 http://localhost:23367",
"ATK_TRUSTED_DOMAINS": "http://localhost:5173 http://localhost:23367"
},
"args": ["server", "-c", "${workspaceFolder}/artalk.yml"]
}
Expand Down
108 changes: 107 additions & 1 deletion docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const docTemplate = `{
},
"/auth/email/register": {
"post": {
"description": "Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)",
"description": "Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -2866,6 +2866,80 @@ const docTemplate = `{
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Update user profile when user is logged in",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Auth"
],
"summary": "Update user profile",
"operationId": "UpdateProfile",
"parameters": [
{
"description": "The profile data to update",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestUserInfoUpdate"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.ResponseUserInfoUpdate"
}
},
"400": {
"description": "Bad Request",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.Map"
},
{
"type": "object",
"properties": {
"msg": {
"type": "string"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.Map"
},
{
"type": "object",
"properties": {
"msg": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/user/access_token": {
Expand Down Expand Up @@ -4433,6 +4507,27 @@ const docTemplate = `{
}
}
},
"handler.RequestUserInfoUpdate": {
"type": "object",
"required": [
"email",
"name"
],
"properties": {
"code": {
"type": "string"
},
"email": {
"type": "string"
},
"link": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"handler.ResponseAdminUserList": {
"type": "object",
"required": [
Expand Down Expand Up @@ -5210,6 +5305,17 @@ const docTemplate = `{
}
}
},
"handler.ResponseUserInfoUpdate": {
"type": "object",
"required": [
"user"
],
"properties": {
"user": {
"$ref": "#/definitions/entity.CookedUser"
}
}
},
"handler.ResponseUserLogin": {
"type": "object",
"required": [
Expand Down
108 changes: 107 additions & 1 deletion docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
"/auth/email/register": {
"post": {
"description": "Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)",
"description": "Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -2859,6 +2859,80 @@
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Update user profile when user is logged in",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Auth"
],
"summary": "Update user profile",
"operationId": "UpdateProfile",
"parameters": [
{
"description": "The profile data to update",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestUserInfoUpdate"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.ResponseUserInfoUpdate"
}
},
"400": {
"description": "Bad Request",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.Map"
},
{
"type": "object",
"properties": {
"msg": {
"type": "string"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.Map"
},
{
"type": "object",
"properties": {
"msg": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/user/access_token": {
Expand Down Expand Up @@ -4426,6 +4500,27 @@
}
}
},
"handler.RequestUserInfoUpdate": {
"type": "object",
"required": [
"email",
"name"
],
"properties": {
"code": {
"type": "string"
},
"email": {
"type": "string"
},
"link": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"handler.ResponseAdminUserList": {
"type": "object",
"required": [
Expand Down Expand Up @@ -5203,6 +5298,17 @@
}
}
},
"handler.ResponseUserInfoUpdate": {
"type": "object",
"required": [
"user"
],
"properties": {
"user": {
"$ref": "#/definitions/entity.CookedUser"
}
}
},
"handler.ResponseUserLogin": {
"type": "object",
"required": [
Expand Down
65 changes: 64 additions & 1 deletion docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,20 @@ definitions:
required:
- email
type: object
handler.RequestUserInfoUpdate:
properties:
code:
type: string
email:
type: string
link:
type: string
name:
type: string
required:
- email
- name
type: object
handler.ResponseAdminUserList:
properties:
count:
Expand Down Expand Up @@ -1170,6 +1184,13 @@ definitions:
- notifies_count
- user
type: object
handler.ResponseUserInfoUpdate:
properties:
user:
$ref: '#/definitions/entity.CookedUser'
required:
- user
type: object
handler.ResponseUserLogin:
properties:
token:
Expand Down Expand Up @@ -1299,7 +1320,7 @@ paths:
consumes:
- application/json
description: Register by email and verify code (if user exists, will update
user, like forget password. Need send email verify code first)
user, like forget or change password. Need send email verify code first)
operationId: RegisterByEmail
parameters:
- description: The data to register
Expand Down Expand Up @@ -2905,6 +2926,48 @@ paths:
summary: Get User Info
tags:
- Auth
post:
consumes:
- application/json
description: Update user profile when user is logged in
operationId: UpdateProfile
parameters:
- description: The profile data to update
in: body
name: data
required: true
schema:
$ref: '#/definitions/handler.RequestUserInfoUpdate'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.ResponseUserInfoUpdate'
"400":
description: Bad Request
schema:
allOf:
- $ref: '#/definitions/handler.Map'
- properties:
msg:
type: string
type: object
"500":
description: Internal Server Error
schema:
allOf:
- $ref: '#/definitions/handler.Map'
- properties:
msg:
type: string
type: object
security:
- ApiKeyAuth: []
summary: Update user profile
tags:
- Auth
/user/access_token:
post:
consumes:
Expand Down
2 changes: 1 addition & 1 deletion server/handler/auth_email_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type RequestAuthEmailRegister struct {

// @Id RegisterByEmail
// @Summary Register by email
// @Description Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)
// @Description Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)
// @Tags Auth
// @Param data body RequestAuthEmailRegister true "The data to register"
// @Success 200 {object} ResponseUserLogin
Expand Down
Loading