Skip to content

Commit 5c6345b

Browse files
author
Lasim
committed
feat: implement admin-initiated password reset functionality with email notification
1 parent 961c25d commit 5c6345b

File tree

10 files changed

+1502
-0
lines changed

10 files changed

+1502
-0
lines changed

services/backend/api-spec.json

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6979,6 +6979,199 @@
69796979
}
69806980
}
69816981
},
6982+
"/api/auth/admin/reset-password": {
6983+
"post": {
6984+
"summary": "Admin-initiated password reset",
6985+
"tags": [
6986+
"Authentication",
6987+
"Admin"
6988+
],
6989+
"description": "Allows global administrators to initiate password reset for users with email authentication. The admin cannot reset their own password. Requires global_send_mail setting to be enabled. The user will receive an email with a reset link that works the same as self-initiated password resets.",
6990+
"requestBody": {
6991+
"content": {
6992+
"application/json": {
6993+
"schema": {
6994+
"type": "object",
6995+
"properties": {
6996+
"email": {
6997+
"type": "string",
6998+
"format": "email"
6999+
}
7000+
},
7001+
"required": [
7002+
"email"
7003+
],
7004+
"additionalProperties": false
7005+
}
7006+
}
7007+
},
7008+
"required": true
7009+
},
7010+
"security": [
7011+
{
7012+
"cookieAuth": []
7013+
}
7014+
],
7015+
"responses": {
7016+
"200": {
7017+
"description": "Password reset email sent successfully",
7018+
"content": {
7019+
"application/json": {
7020+
"schema": {
7021+
"type": "object",
7022+
"properties": {
7023+
"success": {
7024+
"type": "boolean",
7025+
"description": "Indicates if the request was processed successfully"
7026+
},
7027+
"message": {
7028+
"type": "string",
7029+
"description": "Success message"
7030+
}
7031+
},
7032+
"required": [
7033+
"success",
7034+
"message"
7035+
],
7036+
"additionalProperties": false,
7037+
"description": "Password reset email sent successfully"
7038+
}
7039+
}
7040+
}
7041+
},
7042+
"400": {
7043+
"description": "Bad Request - Invalid email, user not found, or user not eligible",
7044+
"content": {
7045+
"application/json": {
7046+
"schema": {
7047+
"type": "object",
7048+
"properties": {
7049+
"success": {
7050+
"type": "boolean",
7051+
"description": "Indicates if the operation was successful (false for errors)",
7052+
"default": false
7053+
},
7054+
"error": {
7055+
"type": "string",
7056+
"description": "Error message describing what went wrong"
7057+
}
7058+
},
7059+
"required": [
7060+
"error"
7061+
],
7062+
"additionalProperties": false,
7063+
"description": "Bad Request - Invalid email, user not found, or user not eligible"
7064+
}
7065+
}
7066+
}
7067+
},
7068+
"401": {
7069+
"description": "Unauthorized - Authentication required",
7070+
"content": {
7071+
"application/json": {
7072+
"schema": {
7073+
"type": "object",
7074+
"properties": {
7075+
"success": {
7076+
"type": "boolean",
7077+
"description": "Indicates if the operation was successful (false for errors)",
7078+
"default": false
7079+
},
7080+
"error": {
7081+
"type": "string",
7082+
"description": "Error message describing what went wrong"
7083+
}
7084+
},
7085+
"required": [
7086+
"error"
7087+
],
7088+
"additionalProperties": false,
7089+
"description": "Unauthorized - Authentication required"
7090+
}
7091+
}
7092+
}
7093+
},
7094+
"403": {
7095+
"description": "Forbidden - Insufficient permissions or self-reset attempt",
7096+
"content": {
7097+
"application/json": {
7098+
"schema": {
7099+
"type": "object",
7100+
"properties": {
7101+
"success": {
7102+
"type": "boolean",
7103+
"description": "Indicates if the operation was successful (false for errors)",
7104+
"default": false
7105+
},
7106+
"error": {
7107+
"type": "string",
7108+
"description": "Error message describing what went wrong"
7109+
}
7110+
},
7111+
"required": [
7112+
"error"
7113+
],
7114+
"additionalProperties": false,
7115+
"description": "Forbidden - Insufficient permissions or self-reset attempt"
7116+
}
7117+
}
7118+
}
7119+
},
7120+
"500": {
7121+
"description": "Internal Server Error - Password reset failed",
7122+
"content": {
7123+
"application/json": {
7124+
"schema": {
7125+
"type": "object",
7126+
"properties": {
7127+
"success": {
7128+
"type": "boolean",
7129+
"description": "Indicates if the operation was successful (false for errors)",
7130+
"default": false
7131+
},
7132+
"error": {
7133+
"type": "string",
7134+
"description": "Error message describing what went wrong"
7135+
}
7136+
},
7137+
"required": [
7138+
"error"
7139+
],
7140+
"additionalProperties": false,
7141+
"description": "Internal Server Error - Password reset failed"
7142+
}
7143+
}
7144+
}
7145+
},
7146+
"503": {
7147+
"description": "Service Unavailable - Email functionality disabled",
7148+
"content": {
7149+
"application/json": {
7150+
"schema": {
7151+
"type": "object",
7152+
"properties": {
7153+
"success": {
7154+
"type": "boolean",
7155+
"description": "Indicates if the operation was successful (false for errors)",
7156+
"default": false
7157+
},
7158+
"error": {
7159+
"type": "string",
7160+
"description": "Error message describing what went wrong"
7161+
}
7162+
},
7163+
"required": [
7164+
"error"
7165+
],
7166+
"additionalProperties": false,
7167+
"description": "Service Unavailable - Email functionality disabled"
7168+
}
7169+
}
7170+
}
7171+
}
7172+
}
7173+
}
7174+
},
69827175
"/api/auth/profile/update": {
69837176
"put": {
69847177
"summary": "Update user profile",
@@ -7144,6 +7337,32 @@
71447337
}
71457338
}
71467339
},
7340+
"403": {
7341+
"description": "Forbidden - Cannot change username for non-email users",
7342+
"content": {
7343+
"application/json": {
7344+
"schema": {
7345+
"type": "object",
7346+
"properties": {
7347+
"success": {
7348+
"type": "boolean",
7349+
"description": "Indicates if the operation was successful (false for errors)",
7350+
"default": false
7351+
},
7352+
"error": {
7353+
"type": "string",
7354+
"description": "Error message describing what went wrong"
7355+
}
7356+
},
7357+
"required": [
7358+
"error"
7359+
],
7360+
"additionalProperties": false,
7361+
"description": "Forbidden - Cannot change username for non-email users"
7362+
}
7363+
}
7364+
}
7365+
},
71477366
"500": {
71487367
"description": "Internal Server Error - Profile update failed",
71497368
"content": {

services/backend/api-spec.yaml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4867,6 +4867,141 @@ paths:
48674867
- error
48684868
additionalProperties: false
48694869
description: Service Unavailable - Email functionality disabled
4870+
/api/auth/admin/reset-password:
4871+
post:
4872+
summary: Admin-initiated password reset
4873+
tags:
4874+
- Authentication
4875+
- Admin
4876+
description: Allows global administrators to initiate password reset for users
4877+
with email authentication. The admin cannot reset their own password.
4878+
Requires global_send_mail setting to be enabled. The user will receive
4879+
an email with a reset link that works the same as self-initiated
4880+
password resets.
4881+
requestBody:
4882+
content:
4883+
application/json:
4884+
schema:
4885+
type: object
4886+
properties:
4887+
email:
4888+
type: string
4889+
format: email
4890+
required:
4891+
- email
4892+
additionalProperties: false
4893+
required: true
4894+
security:
4895+
- cookieAuth: []
4896+
responses:
4897+
"200":
4898+
description: Password reset email sent successfully
4899+
content:
4900+
application/json:
4901+
schema:
4902+
type: object
4903+
properties:
4904+
success:
4905+
type: boolean
4906+
description: Indicates if the request was processed successfully
4907+
message:
4908+
type: string
4909+
description: Success message
4910+
required:
4911+
- success
4912+
- message
4913+
additionalProperties: false
4914+
description: Password reset email sent successfully
4915+
"400":
4916+
description: Bad Request - Invalid email, user not found, or user not eligible
4917+
content:
4918+
application/json:
4919+
schema:
4920+
type: object
4921+
properties:
4922+
success:
4923+
type: boolean
4924+
description: Indicates if the operation was successful (false for errors)
4925+
default: false
4926+
error:
4927+
type: string
4928+
description: Error message describing what went wrong
4929+
required:
4930+
- error
4931+
additionalProperties: false
4932+
description: Bad Request - Invalid email, user not found, or user not eligible
4933+
"401":
4934+
description: Unauthorized - Authentication required
4935+
content:
4936+
application/json:
4937+
schema:
4938+
type: object
4939+
properties:
4940+
success:
4941+
type: boolean
4942+
description: Indicates if the operation was successful (false for errors)
4943+
default: false
4944+
error:
4945+
type: string
4946+
description: Error message describing what went wrong
4947+
required:
4948+
- error
4949+
additionalProperties: false
4950+
description: Unauthorized - Authentication required
4951+
"403":
4952+
description: Forbidden - Insufficient permissions or self-reset attempt
4953+
content:
4954+
application/json:
4955+
schema:
4956+
type: object
4957+
properties:
4958+
success:
4959+
type: boolean
4960+
description: Indicates if the operation was successful (false for errors)
4961+
default: false
4962+
error:
4963+
type: string
4964+
description: Error message describing what went wrong
4965+
required:
4966+
- error
4967+
additionalProperties: false
4968+
description: Forbidden - Insufficient permissions or self-reset attempt
4969+
"500":
4970+
description: Internal Server Error - Password reset failed
4971+
content:
4972+
application/json:
4973+
schema:
4974+
type: object
4975+
properties:
4976+
success:
4977+
type: boolean
4978+
description: Indicates if the operation was successful (false for errors)
4979+
default: false
4980+
error:
4981+
type: string
4982+
description: Error message describing what went wrong
4983+
required:
4984+
- error
4985+
additionalProperties: false
4986+
description: Internal Server Error - Password reset failed
4987+
"503":
4988+
description: Service Unavailable - Email functionality disabled
4989+
content:
4990+
application/json:
4991+
schema:
4992+
type: object
4993+
properties:
4994+
success:
4995+
type: boolean
4996+
description: Indicates if the operation was successful (false for errors)
4997+
default: false
4998+
error:
4999+
type: string
5000+
description: Error message describing what went wrong
5001+
required:
5002+
- error
5003+
additionalProperties: false
5004+
description: Service Unavailable - Email functionality disabled
48705005
/api/auth/profile/update:
48715006
put:
48725007
summary: Update user profile
@@ -4990,6 +5125,24 @@ paths:
49905125
- error
49915126
additionalProperties: false
49925127
description: Unauthorized - Authentication required
5128+
"403":
5129+
description: Forbidden - Cannot change username for non-email users
5130+
content:
5131+
application/json:
5132+
schema:
5133+
type: object
5134+
properties:
5135+
success:
5136+
type: boolean
5137+
description: Indicates if the operation was successful (false for errors)
5138+
default: false
5139+
error:
5140+
type: string
5141+
description: Error message describing what went wrong
5142+
required:
5143+
- error
5144+
additionalProperties: false
5145+
description: Forbidden - Cannot change username for non-email users
49935146
"500":
49945147
description: Internal Server Error - Profile update failed
49955148
content:

0 commit comments

Comments
 (0)