feat: recover password & refresh token

This commit is contained in:
2025-07-20 18:06:05 +01:00
parent 57730270a0
commit f85191b918
26 changed files with 748 additions and 332 deletions
+196 -42
View File
@@ -24,6 +24,46 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/admin/users": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Fetches all users",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Fetches all users",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/store.User"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"404": {
"description": "Not Found",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/forgot-password": {
"post": {
"description": "Forgot Password",
@@ -70,6 +110,92 @@ const docTemplate = `{
}
}
},
"/authentication/refresh": {
"post": {
"description": "Refresh a token for the user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Refresh a token",
"parameters": [
{
"type": "string",
"description": "Refresh Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"201": {
"description": "Token Created",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/register": {
"post": {
"description": "Register a new User",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Register a new User",
"parameters": [
{
"description": "User Credentials",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.RegisterUserPayload"
}
}
],
"responses": {
"201": {
"description": "User Registered",
"schema": {
"$ref": "#/definitions/main.UserWithToken"
}
},
"400": {
"description": "User payload error",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/token": {
"post": {
"description": "Create a new token for the user",
@@ -116,48 +242,6 @@ const docTemplate = `{
}
}
},
"/authentication/user": {
"post": {
"description": "Register a new User",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Register a new User",
"parameters": [
{
"description": "User Credentials",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.RegisterUserPayload"
}
}
],
"responses": {
"201": {
"description": "User Registered",
"schema": {
"$ref": "#/definitions/main.UserWithToken"
}
},
"400": {
"description": "User payload error",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/health": {
"get": {
"description": "Health Check",
@@ -555,6 +639,61 @@ const docTemplate = `{
}
}
},
"/users/reset-password/{token}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Reset user password with verification",
"consumes": [
"application/json"
],
"tags": [
"users"
],
"summary": "Reset user password",
"parameters": [
{
"description": "Reset Password",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.resetPasswordPayload"
}
},
{
"type": "string",
"description": "Reset Password Token",
"name": "token",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "Password reset successfully",
"schema": {
"type": "string"
}
},
"400": {
"description": "Invalid request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"500": {
"description": "Internal server error",
"schema": {}
}
}
}
},
"/users/{id}": {
"get": {
"security": [
@@ -935,6 +1074,21 @@ const docTemplate = `{
}
}
},
"main.resetPasswordPayload": {
"type": "object",
"required": [
"new_password",
"new_password_confirmation"
],
"properties": {
"new_password": {
"type": "string"
},
"new_password_confirmation": {
"type": "string"
}
}
},
"main.updateUserPasswordPayload": {
"type": "object",
"required": [
+196 -42
View File
@@ -16,6 +16,46 @@
},
"basePath": "/v1",
"paths": {
"/admin/users": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Fetches all users",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Fetches all users",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/store.User"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"404": {
"description": "Not Found",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/forgot-password": {
"post": {
"description": "Forgot Password",
@@ -62,6 +102,92 @@
}
}
},
"/authentication/refresh": {
"post": {
"description": "Refresh a token for the user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Refresh a token",
"parameters": [
{
"type": "string",
"description": "Refresh Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"201": {
"description": "Token Created",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/register": {
"post": {
"description": "Register a new User",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Register a new User",
"parameters": [
{
"description": "User Credentials",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.RegisterUserPayload"
}
}
],
"responses": {
"201": {
"description": "User Registered",
"schema": {
"$ref": "#/definitions/main.UserWithToken"
}
},
"400": {
"description": "User payload error",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/authentication/token": {
"post": {
"description": "Create a new token for the user",
@@ -108,48 +234,6 @@
}
}
},
"/authentication/user": {
"post": {
"description": "Register a new User",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authentication"
],
"summary": "Register a new User",
"parameters": [
{
"description": "User Credentials",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.RegisterUserPayload"
}
}
],
"responses": {
"201": {
"description": "User Registered",
"schema": {
"$ref": "#/definitions/main.UserWithToken"
}
},
"400": {
"description": "User payload error",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/health": {
"get": {
"description": "Health Check",
@@ -547,6 +631,61 @@
}
}
},
"/users/reset-password/{token}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Reset user password with verification",
"consumes": [
"application/json"
],
"tags": [
"users"
],
"summary": "Reset user password",
"parameters": [
{
"description": "Reset Password",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.resetPasswordPayload"
}
},
{
"type": "string",
"description": "Reset Password Token",
"name": "token",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "Password reset successfully",
"schema": {
"type": "string"
}
},
"400": {
"description": "Invalid request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"500": {
"description": "Internal server error",
"schema": {}
}
}
}
},
"/users/{id}": {
"get": {
"security": [
@@ -927,6 +1066,21 @@
}
}
},
"main.resetPasswordPayload": {
"type": "object",
"required": [
"new_password",
"new_password_confirmation"
],
"properties": {
"new_password": {
"type": "string"
},
"new_password_confirmation": {
"type": "string"
}
}
},
"main.updateUserPasswordPayload": {
"type": "object",
"required": [
+130 -28
View File
@@ -94,6 +94,16 @@ definitions:
username:
type: string
type: object
main.resetPasswordPayload:
properties:
new_password:
type: string
new_password_confirmation:
type: string
required:
- new_password
- new_password_confirmation
type: object
main.updateUserPasswordPayload:
properties:
current_password:
@@ -238,6 +248,32 @@ info:
termsOfService: http://swagger.io/terms/
title: LK API Template
paths:
/admin/users:
get:
consumes:
- application/json
description: Fetches all users
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/store.User'
"400":
description: Bad Request
schema: {}
"404":
description: Not Found
schema: {}
"500":
description: Internal Server Error
schema: {}
security:
- ApiKeyAuth: []
summary: Fetches all users
tags:
- admin
/authentication/forgot-password:
post:
consumes:
@@ -269,6 +305,64 @@ paths:
summary: Forgot Password
tags:
- authentication
/authentication/refresh:
post:
consumes:
- application/json
description: Refresh a token for the user
parameters:
- description: Refresh Token
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"201":
description: Token Created
schema:
type: string
"400":
description: Bad Request
schema: {}
"401":
description: Unauthorized
schema: {}
"500":
description: Internal Server Error
schema: {}
summary: Refresh a token
tags:
- authentication
/authentication/register:
post:
consumes:
- application/json
description: Register a new User
parameters:
- description: User Credentials
in: body
name: payload
required: true
schema:
$ref: '#/definitions/main.RegisterUserPayload'
produces:
- application/json
responses:
"201":
description: User Registered
schema:
$ref: '#/definitions/main.UserWithToken'
"400":
description: User payload error
schema: {}
"500":
description: Internal Server Error
schema: {}
summary: Register a new User
tags:
- authentication
/authentication/token:
post:
consumes:
@@ -300,34 +394,6 @@ paths:
summary: Create a new token
tags:
- authentication
/authentication/user:
post:
consumes:
- application/json
description: Register a new User
parameters:
- description: User Credentials
in: body
name: payload
required: true
schema:
$ref: '#/definitions/main.RegisterUserPayload'
produces:
- application/json
responses:
"201":
description: User Registered
schema:
$ref: '#/definitions/main.UserWithToken'
"400":
description: User payload error
schema: {}
"500":
description: Internal Server Error
schema: {}
summary: Register a new User
tags:
- authentication
/health:
get:
description: Health Check
@@ -756,6 +822,42 @@ paths:
summary: Fetches the user feed
tags:
- feed
/users/reset-password/{token}:
put:
consumes:
- application/json
description: Reset user password with verification
parameters:
- description: Reset Password
in: body
name: payload
required: true
schema:
$ref: '#/definitions/main.resetPasswordPayload'
- description: Reset Password Token
in: path
name: token
required: true
type: string
responses:
"204":
description: Password reset successfully
schema:
type: string
"400":
description: Invalid request
schema: {}
"401":
description: Unauthorized
schema: {}
"500":
description: Internal server error
schema: {}
security:
- ApiKeyAuth: []
summary: Reset user password
tags:
- users
securityDefinitions:
ApiKeyAuth:
in: header