diff --git a/docs/docs.go b/docs/docs.go
index a256fba5..02938521 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1164,6 +1164,79 @@ const docTemplate = `{
}
}
}
+ },
+ "post": {
+ "security": [
+ {
+ "SessionCookie": []
+ }
+ ],
+ "description": "创建一个本地密码登录的新用户,需要管理员权限",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "创建用户",
+ "parameters": [
+ {
+ "description": "创建用户参数",
+ "name": "request",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/user.createUserRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "创建成功",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseAny"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/user.user"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "400": {
+ "description": "参数错误或用户名已存在",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "401": {
+ "description": "未登录",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "403": {
+ "description": "无管理员权限",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "500": {
+ "description": "内部错误",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ }
+ }
}
},
"/api/v1/admin/users/{id}/status": {
@@ -2223,6 +2296,64 @@ const docTemplate = `{
}
}
},
+ "/api/v1/user/change-password": {
+ "post": {
+ "description": "修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "user"
+ ],
+ "summary": "修改用户密码",
+ "parameters": [
+ {
+ "description": "修改密码请求参数",
+ "name": "request",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/user.changePasswordRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "修改密码成功",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseAny"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "400": {
+ "description": "原密码错误或新密码不符合要求",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "401": {
+ "description": "请先登录",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ }
+ }
+ }
+ },
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
@@ -2665,23 +2796,6 @@ const docTemplate = `{
"TaskExecutionStatusFailed"
]
},
- "model.TrustLevel": {
- "type": "integer",
- "enum": [
- 0,
- 1,
- 2,
- 3,
- 4
- ],
- "x-enum-varnames": [
- "TrustLevelNewUser",
- "TrustLevelBasicUser",
- "TrustLevelUser",
- "TrustLevelActiveUser",
- "TrustLevelLeader"
- ]
- },
"model.Upload": {
"type": "object",
"properties": {
@@ -2834,54 +2948,21 @@ const docTemplate = `{
"oauth.BasicUserInfo": {
"type": "object",
"properties": {
- "available_balance": {
- "type": "number"
- },
"avatar_url": {
"type": "string"
},
- "community_balance": {
- "type": "number"
- },
- "daily_limit": {
- "type": "integer"
- },
"id": {
"type": "integer"
},
"is_admin": {
"type": "boolean"
},
+ "need_change_password": {
+ "type": "boolean"
+ },
"nickname": {
"type": "string"
},
- "pay_level": {
- "type": "string"
- },
- "pay_score": {
- "type": "integer"
- },
- "pending_balance": {
- "type": "number"
- },
- "remain_quota": {
- "type": "number"
- },
- "total_community": {
- "type": "number"
- },
- "total_payment": {
- "type": "number"
- },
- "total_receive": {
- "type": "number"
- },
- "total_transfer": {
- "type": "number"
- },
- "trust_level": {
- "$ref": "#/definitions/model.TrustLevel"
- },
"username": {
"type": "string"
}
@@ -3051,6 +3132,17 @@ const docTemplate = `{
}
}
},
+ "user.changePasswordRequest": {
+ "type": "object",
+ "properties": {
+ "new_password": {
+ "type": "string"
+ },
+ "old_password": {
+ "type": "string"
+ }
+ }
+ },
"user.createTokenRequest": {
"type": "object",
"properties": {
@@ -3059,6 +3151,35 @@ const docTemplate = `{
}
}
},
+ "user.createUserRequest": {
+ "type": "object",
+ "required": [
+ "password",
+ "username"
+ ],
+ "properties": {
+ "is_active": {
+ "type": "boolean"
+ },
+ "is_admin": {
+ "type": "boolean"
+ },
+ "nickname": {
+ "type": "string",
+ "maxLength": 64
+ },
+ "password": {
+ "type": "string",
+ "maxLength": 64,
+ "minLength": 8
+ },
+ "username": {
+ "type": "string",
+ "maxLength": 64,
+ "minLength": 3
+ }
+ }
+ },
"user.listUsersResponse": {
"type": "object",
"properties": {
@@ -3123,15 +3244,9 @@ const docTemplate = `{
"user.user": {
"type": "object",
"properties": {
- "available_balance": {
- "type": "number"
- },
"avatar_url": {
"type": "string"
},
- "community_balance": {
- "type": "number"
- },
"created_at": {
"type": "string"
},
@@ -3150,24 +3265,6 @@ const docTemplate = `{
"nickname": {
"type": "string"
},
- "pay_score": {
- "type": "integer"
- },
- "total_community": {
- "type": "number"
- },
- "total_payment": {
- "type": "number"
- },
- "total_receive": {
- "type": "number"
- },
- "total_transfer": {
- "type": "number"
- },
- "trust_level": {
- "$ref": "#/definitions/model.TrustLevel"
- },
"updated_at": {
"type": "string"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 4ccaea83..ab433e34 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1157,6 +1157,79 @@
}
}
}
+ },
+ "post": {
+ "security": [
+ {
+ "SessionCookie": []
+ }
+ ],
+ "description": "创建一个本地密码登录的新用户,需要管理员权限",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "创建用户",
+ "parameters": [
+ {
+ "description": "创建用户参数",
+ "name": "request",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/user.createUserRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "创建成功",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseAny"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/user.user"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "400": {
+ "description": "参数错误或用户名已存在",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "401": {
+ "description": "未登录",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "403": {
+ "description": "无管理员权限",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "500": {
+ "description": "内部错误",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ }
+ }
}
},
"/api/v1/admin/users/{id}/status": {
@@ -2216,6 +2289,64 @@
}
}
},
+ "/api/v1/user/change-password": {
+ "post": {
+ "description": "修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "user"
+ ],
+ "summary": "修改用户密码",
+ "parameters": [
+ {
+ "description": "修改密码请求参数",
+ "name": "request",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/user.changePasswordRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "修改密码成功",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseAny"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "400": {
+ "description": "原密码错误或新密码不符合要求",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ },
+ "401": {
+ "description": "请先登录",
+ "schema": {
+ "$ref": "#/definitions/util.ResponseAny"
+ }
+ }
+ }
+ }
+ },
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
@@ -2658,23 +2789,6 @@
"TaskExecutionStatusFailed"
]
},
- "model.TrustLevel": {
- "type": "integer",
- "enum": [
- 0,
- 1,
- 2,
- 3,
- 4
- ],
- "x-enum-varnames": [
- "TrustLevelNewUser",
- "TrustLevelBasicUser",
- "TrustLevelUser",
- "TrustLevelActiveUser",
- "TrustLevelLeader"
- ]
- },
"model.Upload": {
"type": "object",
"properties": {
@@ -2827,54 +2941,21 @@
"oauth.BasicUserInfo": {
"type": "object",
"properties": {
- "available_balance": {
- "type": "number"
- },
"avatar_url": {
"type": "string"
},
- "community_balance": {
- "type": "number"
- },
- "daily_limit": {
- "type": "integer"
- },
"id": {
"type": "integer"
},
"is_admin": {
"type": "boolean"
},
+ "need_change_password": {
+ "type": "boolean"
+ },
"nickname": {
"type": "string"
},
- "pay_level": {
- "type": "string"
- },
- "pay_score": {
- "type": "integer"
- },
- "pending_balance": {
- "type": "number"
- },
- "remain_quota": {
- "type": "number"
- },
- "total_community": {
- "type": "number"
- },
- "total_payment": {
- "type": "number"
- },
- "total_receive": {
- "type": "number"
- },
- "total_transfer": {
- "type": "number"
- },
- "trust_level": {
- "$ref": "#/definitions/model.TrustLevel"
- },
"username": {
"type": "string"
}
@@ -3044,6 +3125,17 @@
}
}
},
+ "user.changePasswordRequest": {
+ "type": "object",
+ "properties": {
+ "new_password": {
+ "type": "string"
+ },
+ "old_password": {
+ "type": "string"
+ }
+ }
+ },
"user.createTokenRequest": {
"type": "object",
"properties": {
@@ -3052,6 +3144,35 @@
}
}
},
+ "user.createUserRequest": {
+ "type": "object",
+ "required": [
+ "password",
+ "username"
+ ],
+ "properties": {
+ "is_active": {
+ "type": "boolean"
+ },
+ "is_admin": {
+ "type": "boolean"
+ },
+ "nickname": {
+ "type": "string",
+ "maxLength": 64
+ },
+ "password": {
+ "type": "string",
+ "maxLength": 64,
+ "minLength": 8
+ },
+ "username": {
+ "type": "string",
+ "maxLength": 64,
+ "minLength": 3
+ }
+ }
+ },
"user.listUsersResponse": {
"type": "object",
"properties": {
@@ -3116,15 +3237,9 @@
"user.user": {
"type": "object",
"properties": {
- "available_balance": {
- "type": "number"
- },
"avatar_url": {
"type": "string"
},
- "community_balance": {
- "type": "number"
- },
"created_at": {
"type": "string"
},
@@ -3143,24 +3258,6 @@
"nickname": {
"type": "string"
},
- "pay_score": {
- "type": "integer"
- },
- "total_community": {
- "type": "number"
- },
- "total_payment": {
- "type": "number"
- },
- "total_receive": {
- "type": "number"
- },
- "total_transfer": {
- "type": "number"
- },
- "trust_level": {
- "$ref": "#/definitions/model.TrustLevel"
- },
"updated_at": {
"type": "string"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 5a001adf..4f715890 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -156,20 +156,6 @@ definitions:
- TaskExecutionStatusRunning
- TaskExecutionStatusSucceeded
- TaskExecutionStatusFailed
- model.TrustLevel:
- enum:
- - 0
- - 1
- - 2
- - 3
- - 4
- type: integer
- x-enum-varnames:
- - TrustLevelNewUser
- - TrustLevelBasicUser
- - TrustLevelUser
- - TrustLevelActiveUser
- - TrustLevelLeader
model.Upload:
properties:
created_at:
@@ -276,38 +262,16 @@ definitions:
type: object
oauth.BasicUserInfo:
properties:
- available_balance:
- type: number
avatar_url:
type: string
- community_balance:
- type: number
- daily_limit:
- type: integer
id:
type: integer
is_admin:
type: boolean
+ need_change_password:
+ type: boolean
nickname:
type: string
- pay_level:
- type: string
- pay_score:
- type: integer
- pending_balance:
- type: number
- remain_quota:
- type: number
- total_community:
- type: number
- total_payment:
- type: number
- total_receive:
- type: number
- total_transfer:
- type: number
- trust_level:
- $ref: '#/definitions/model.TrustLevel'
username:
type: string
type: object
@@ -421,11 +385,39 @@ definitions:
total:
type: integer
type: object
+ user.changePasswordRequest:
+ properties:
+ new_password:
+ type: string
+ old_password:
+ type: string
+ type: object
user.createTokenRequest:
properties:
name:
type: string
type: object
+ user.createUserRequest:
+ properties:
+ is_active:
+ type: boolean
+ is_admin:
+ type: boolean
+ nickname:
+ maxLength: 64
+ type: string
+ password:
+ maxLength: 64
+ minLength: 8
+ type: string
+ username:
+ maxLength: 64
+ minLength: 3
+ type: string
+ required:
+ - password
+ - username
+ type: object
user.listUsersResponse:
properties:
total:
@@ -467,12 +459,8 @@ definitions:
type: object
user.user:
properties:
- available_balance:
- type: number
avatar_url:
type: string
- community_balance:
- type: number
created_at:
type: string
id:
@@ -485,18 +473,6 @@ definitions:
type: string
nickname:
type: string
- pay_score:
- type: integer
- total_community:
- type: number
- total_payment:
- type: number
- total_receive:
- type: number
- total_transfer:
- type: number
- trust_level:
- $ref: '#/definitions/model.TrustLevel'
updated_at:
type: string
username:
@@ -1208,6 +1184,50 @@ paths:
summary: 获取用户列表
tags:
- admin
+ post:
+ consumes:
+ - application/json
+ description: 创建一个本地密码登录的新用户,需要管理员权限
+ parameters:
+ - description: 创建用户参数
+ in: body
+ name: request
+ required: true
+ schema:
+ $ref: '#/definitions/user.createUserRequest'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 创建成功
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.ResponseAny'
+ - properties:
+ data:
+ $ref: '#/definitions/user.user'
+ type: object
+ "400":
+ description: 参数错误或用户名已存在
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ "401":
+ description: 未登录
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ "403":
+ description: 无管理员权限
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ "500":
+ description: 内部错误
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ security:
+ - SessionCookie: []
+ summary: 创建用户
+ tags:
+ - admin
/api/v1/admin/users/{id}/status:
put:
consumes:
@@ -1838,6 +1858,41 @@ paths:
summary: 轮换一个 AccessToken
tags:
- user
+ /api/v1/user/change-password:
+ post:
+ consumes:
+ - application/json
+ description: 修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。
+ parameters:
+ - description: 修改密码请求参数
+ in: body
+ name: request
+ required: true
+ schema:
+ $ref: '#/definitions/user.changePasswordRequest'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 修改密码成功
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.ResponseAny'
+ - properties:
+ data:
+ type: string
+ type: object
+ "400":
+ description: 原密码错误或新密码不符合要求
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ "401":
+ description: 请先登录
+ schema:
+ $ref: '#/definitions/util.ResponseAny'
+ summary: 修改用户密码
+ tags:
+ - user
/api/v1/user/login:
post:
consumes:
diff --git a/frontend/app/(main)/settings/files/page.tsx b/frontend/app/(main)/admin/files/page.tsx
similarity index 51%
rename from frontend/app/(main)/settings/files/page.tsx
rename to frontend/app/(main)/admin/files/page.tsx
index a91770c4..fbfcef22 100644
--- a/frontend/app/(main)/settings/files/page.tsx
+++ b/frontend/app/(main)/admin/files/page.tsx
@@ -1,4 +1,4 @@
-import {FilesMain} from "@/components/common/settings/files"
+import {FilesMain} from "@/components/common/admin/files"
export default function FilesPage() {
return
diff --git a/frontend/components/auth/login-form.tsx b/frontend/components/auth/login-form.tsx
index 2264d35f..92df2bcd 100644
--- a/frontend/components/auth/login-form.tsx
+++ b/frontend/components/auth/login-form.tsx
@@ -46,12 +46,12 @@ export function LoginForm() {
const publicConfigQuery = useQuery({
queryKey: ["public-config"],
- queryFn: services.config.getPublicConfig,
+ queryFn: () => services.config.getPublicConfig(),
})
const authSourcesQuery = useQuery({
queryKey: ["auth-sources"],
- queryFn: services.auth.getAuthSources,
+ queryFn: () => services.auth.getAuthSources(),
enabled: publicConfigQuery.data?.oidc_login_enabled ?? true,
})
@@ -61,7 +61,7 @@ export function LoginForm() {
)
const loginMutation = useMutation({
- mutationFn: services.auth.login,
+ mutationFn: (req: any) => services.auth.login(req),
onSuccess: (user) => {
setUser(user)
router.replace(redirectTarget)
@@ -72,7 +72,7 @@ export function LoginForm() {
})
const registerMutation = useMutation({
- mutationFn: services.auth.register,
+ mutationFn: (req: any) => services.auth.register(req),
onSuccess: (user) => {
setUser(user)
router.replace(redirectTarget)
@@ -125,9 +125,6 @@ export function LoginForm() {
账号登录
-
- 使用账号密码或第三方 OIDC 认证源登录
-
setMode(value as "login" | "register")}>
@@ -165,6 +162,7 @@ export function LoginForm() {
@@ -216,6 +214,7 @@ export function LoginForm() {