feat(plugin): add user center config user role API

This commit is contained in:
LinkinStars 2023-04-16 12:39:02 +08:00
parent 0f7121d6fe
commit a2ba1144ee
11 changed files with 602 additions and 58 deletions

View File

@ -1301,6 +1301,77 @@ const docTemplate = `{
} }
} }
}, },
"/answer/admin/api/siteinfo/users": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get site user config",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "get site user config",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.SiteUsersResp"
}
}
}
]
}
}
}
},
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "update site info config about users",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "update site info config about users",
"parameters": [
{
"description": "users info",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.SiteUsersReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/admin/api/siteinfo/write": { "/answer/admin/api/siteinfo/write": {
"get": { "get": {
"security": [ "security": [
@ -6149,12 +6220,21 @@ const docTemplate = `{
} }
} }
}, },
"schema.ConfigFields": { "schema.ConfigField": {
"type": "object", "type": "object",
"properties": { "properties": {
"description": { "description": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.ConfigFieldOption"
}
},
"required": { "required": {
"type": "boolean" "type": "boolean"
}, },
@ -6164,14 +6244,40 @@ const docTemplate = `{
"type": { "type": {
"type": "string" "type": "string"
}, },
"ui_widget": { "ui_options": {
"$ref": "#/definitions/schema.UIWidget" "$ref": "#/definitions/schema.ConfigFieldUIOptions"
},
"value": {}
}
},
"schema.ConfigFieldOption": {
"type": "object",
"properties": {
"label": {
"type": "string"
}, },
"value": { "value": {
"type": "string" "type": "string"
} }
} }
}, },
"schema.ConfigFieldUIOptions": {
"type": "object",
"properties": {
"input_type": {
"type": "string"
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"rows": {
"type": "string"
}
}
},
"schema.ConnectorInfoResp": { "schema.ConnectorInfoResp": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -6532,14 +6638,13 @@ const docTemplate = `{
"config_fields": { "config_fields": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/schema.ConfigFields" "$ref": "#/definitions/schema.ConfigField"
} }
}, },
"description": { "description": {
"type": "string" "type": "string"
}, },
"name": { "name": {
"description": "ConfigFields []plugin.ConfigField ` + "`" + `json:\"config_fields\"` + "`" + `",
"type": "string" "type": "string"
}, },
"slug_name": { "slug_name": {
@ -6562,6 +6667,9 @@ const docTemplate = `{
"have_config": { "have_config": {
"type": "boolean" "type": "boolean"
}, },
"link": {
"type": "string"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
@ -7009,6 +7117,10 @@ const docTemplate = `{
"description": "follow count", "description": "follow count",
"type": "integer" "type": "integer"
}, },
"have_password": {
"description": "user have password",
"type": "boolean"
},
"id": { "id": {
"description": "user id", "description": "user id",
"type": "string" "type": "string"
@ -7109,6 +7221,9 @@ const docTemplate = `{
"description": "follow count", "description": "follow count",
"type": "integer" "type": "integer"
}, },
"have_password": {
"type": "boolean"
},
"id": { "id": {
"description": "user id", "description": "user id",
"type": "string" "type": "string"
@ -7802,6 +7917,9 @@ const docTemplate = `{
"site_seo": { "site_seo": {
"$ref": "#/definitions/schema.SiteSeoReq" "$ref": "#/definitions/schema.SiteSeoReq"
}, },
"site_users": {
"$ref": "#/definitions/schema.SiteUsersResp"
},
"theme": { "theme": {
"$ref": "#/definitions/schema.SiteThemeResp" "$ref": "#/definitions/schema.SiteThemeResp"
}, },
@ -7897,6 +8015,15 @@ const docTemplate = `{
"schema.SiteLoginReq": { "schema.SiteLoginReq": {
"type": "object", "type": "object",
"properties": { "properties": {
"allow_email_domains": {
"type": "array",
"items": {
"type": "string"
}
},
"allow_email_registrations": {
"type": "boolean"
},
"allow_new_registrations": { "allow_new_registrations": {
"type": "boolean" "type": "boolean"
}, },
@ -7908,6 +8035,15 @@ const docTemplate = `{
"schema.SiteLoginResp": { "schema.SiteLoginResp": {
"type": "object", "type": "object",
"properties": { "properties": {
"allow_email_domains": {
"type": "array",
"items": {
"type": "string"
}
},
"allow_email_registrations": {
"type": "boolean"
},
"allow_new_registrations": { "allow_new_registrations": {
"type": "boolean" "type": "boolean"
}, },
@ -7984,6 +8120,72 @@ const docTemplate = `{
} }
} }
}, },
"schema.SiteUsersReq": {
"type": "object",
"required": [
"default_avatar"
],
"properties": {
"allow_update_avatar": {
"type": "boolean"
},
"allow_update_bio": {
"type": "boolean"
},
"allow_update_display_name": {
"type": "boolean"
},
"allow_update_location": {
"type": "boolean"
},
"allow_update_username": {
"type": "boolean"
},
"allow_update_website": {
"type": "boolean"
},
"default_avatar": {
"type": "string",
"enum": [
"system",
"gravatar"
]
}
}
},
"schema.SiteUsersResp": {
"type": "object",
"required": [
"default_avatar"
],
"properties": {
"allow_update_avatar": {
"type": "boolean"
},
"allow_update_bio": {
"type": "boolean"
},
"allow_update_display_name": {
"type": "boolean"
},
"allow_update_location": {
"type": "boolean"
},
"allow_update_username": {
"type": "boolean"
},
"allow_update_website": {
"type": "boolean"
},
"default_avatar": {
"type": "string",
"enum": [
"system",
"gravatar"
]
}
}
},
"schema.SiteWriteReq": { "schema.SiteWriteReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8096,17 +8298,6 @@ const docTemplate = `{
} }
} }
}, },
"schema.UIWidget": {
"type": "object",
"properties": {
"placeholder": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"schema.UnreviewedRevisionInfoInfo": { "schema.UnreviewedRevisionInfoInfo": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8493,14 +8684,19 @@ const docTemplate = `{
}, },
"schema.UserModifyPassWordRequest": { "schema.UserModifyPassWordRequest": {
"type": "object", "type": "object",
"required": [
"pass"
],
"properties": { "properties": {
"old_pass": { "old_pass": {
"description": "old password", "type": "string",
"type": "string" "maxLength": 32,
"minLength": 8
}, },
"pass": { "pass": {
"description": "password", "type": "string",
"type": "string" "maxLength": 32,
"minLength": 8
} }
} }
}, },

View File

@ -1289,6 +1289,77 @@
} }
} }
}, },
"/answer/admin/api/siteinfo/users": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get site user config",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "get site user config",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/handler.RespBody"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/schema.SiteUsersResp"
}
}
}
]
}
}
}
},
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "update site info config about users",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "update site info config about users",
"parameters": [
{
"description": "users info",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.SiteUsersReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/admin/api/siteinfo/write": { "/answer/admin/api/siteinfo/write": {
"get": { "get": {
"security": [ "security": [
@ -6137,12 +6208,21 @@
} }
} }
}, },
"schema.ConfigFields": { "schema.ConfigField": {
"type": "object", "type": "object",
"properties": { "properties": {
"description": { "description": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.ConfigFieldOption"
}
},
"required": { "required": {
"type": "boolean" "type": "boolean"
}, },
@ -6152,14 +6232,40 @@
"type": { "type": {
"type": "string" "type": "string"
}, },
"ui_widget": { "ui_options": {
"$ref": "#/definitions/schema.UIWidget" "$ref": "#/definitions/schema.ConfigFieldUIOptions"
},
"value": {}
}
},
"schema.ConfigFieldOption": {
"type": "object",
"properties": {
"label": {
"type": "string"
}, },
"value": { "value": {
"type": "string" "type": "string"
} }
} }
}, },
"schema.ConfigFieldUIOptions": {
"type": "object",
"properties": {
"input_type": {
"type": "string"
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"rows": {
"type": "string"
}
}
},
"schema.ConnectorInfoResp": { "schema.ConnectorInfoResp": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -6520,14 +6626,13 @@
"config_fields": { "config_fields": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/schema.ConfigFields" "$ref": "#/definitions/schema.ConfigField"
} }
}, },
"description": { "description": {
"type": "string" "type": "string"
}, },
"name": { "name": {
"description": "ConfigFields []plugin.ConfigField `json:\"config_fields\"`",
"type": "string" "type": "string"
}, },
"slug_name": { "slug_name": {
@ -6550,6 +6655,9 @@
"have_config": { "have_config": {
"type": "boolean" "type": "boolean"
}, },
"link": {
"type": "string"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
@ -6997,6 +7105,10 @@
"description": "follow count", "description": "follow count",
"type": "integer" "type": "integer"
}, },
"have_password": {
"description": "user have password",
"type": "boolean"
},
"id": { "id": {
"description": "user id", "description": "user id",
"type": "string" "type": "string"
@ -7097,6 +7209,9 @@
"description": "follow count", "description": "follow count",
"type": "integer" "type": "integer"
}, },
"have_password": {
"type": "boolean"
},
"id": { "id": {
"description": "user id", "description": "user id",
"type": "string" "type": "string"
@ -7790,6 +7905,9 @@
"site_seo": { "site_seo": {
"$ref": "#/definitions/schema.SiteSeoReq" "$ref": "#/definitions/schema.SiteSeoReq"
}, },
"site_users": {
"$ref": "#/definitions/schema.SiteUsersResp"
},
"theme": { "theme": {
"$ref": "#/definitions/schema.SiteThemeResp" "$ref": "#/definitions/schema.SiteThemeResp"
}, },
@ -7885,6 +8003,15 @@
"schema.SiteLoginReq": { "schema.SiteLoginReq": {
"type": "object", "type": "object",
"properties": { "properties": {
"allow_email_domains": {
"type": "array",
"items": {
"type": "string"
}
},
"allow_email_registrations": {
"type": "boolean"
},
"allow_new_registrations": { "allow_new_registrations": {
"type": "boolean" "type": "boolean"
}, },
@ -7896,6 +8023,15 @@
"schema.SiteLoginResp": { "schema.SiteLoginResp": {
"type": "object", "type": "object",
"properties": { "properties": {
"allow_email_domains": {
"type": "array",
"items": {
"type": "string"
}
},
"allow_email_registrations": {
"type": "boolean"
},
"allow_new_registrations": { "allow_new_registrations": {
"type": "boolean" "type": "boolean"
}, },
@ -7972,6 +8108,72 @@
} }
} }
}, },
"schema.SiteUsersReq": {
"type": "object",
"required": [
"default_avatar"
],
"properties": {
"allow_update_avatar": {
"type": "boolean"
},
"allow_update_bio": {
"type": "boolean"
},
"allow_update_display_name": {
"type": "boolean"
},
"allow_update_location": {
"type": "boolean"
},
"allow_update_username": {
"type": "boolean"
},
"allow_update_website": {
"type": "boolean"
},
"default_avatar": {
"type": "string",
"enum": [
"system",
"gravatar"
]
}
}
},
"schema.SiteUsersResp": {
"type": "object",
"required": [
"default_avatar"
],
"properties": {
"allow_update_avatar": {
"type": "boolean"
},
"allow_update_bio": {
"type": "boolean"
},
"allow_update_display_name": {
"type": "boolean"
},
"allow_update_location": {
"type": "boolean"
},
"allow_update_username": {
"type": "boolean"
},
"allow_update_website": {
"type": "boolean"
},
"default_avatar": {
"type": "string",
"enum": [
"system",
"gravatar"
]
}
}
},
"schema.SiteWriteReq": { "schema.SiteWriteReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8084,17 +8286,6 @@
} }
} }
}, },
"schema.UIWidget": {
"type": "object",
"properties": {
"placeholder": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"schema.UnreviewedRevisionInfoInfo": { "schema.UnreviewedRevisionInfoInfo": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8481,14 +8672,19 @@
}, },
"schema.UserModifyPassWordRequest": { "schema.UserModifyPassWordRequest": {
"type": "object", "type": "object",
"required": [
"pass"
],
"properties": { "properties": {
"old_pass": { "old_pass": {
"description": "old password", "type": "string",
"type": "string" "maxLength": 32,
"minLength": 8
}, },
"pass": { "pass": {
"description": "password", "type": "string",
"type": "string" "maxLength": 32,
"minLength": 8
} }
} }
}, },

View File

@ -305,21 +305,44 @@ definitions:
switch: switch:
type: boolean type: boolean
type: object type: object
schema.ConfigFields: schema.ConfigField:
properties: properties:
description: description:
type: string type: string
name:
type: string
options:
items:
$ref: '#/definitions/schema.ConfigFieldOption'
type: array
required: required:
type: boolean type: boolean
title: title:
type: string type: string
type: type:
type: string type: string
ui_widget: ui_options:
$ref: '#/definitions/schema.UIWidget' $ref: '#/definitions/schema.ConfigFieldUIOptions'
value: {}
type: object
schema.ConfigFieldOption:
properties:
label:
type: string
value: value:
type: string type: string
type: object type: object
schema.ConfigFieldUIOptions:
properties:
input_type:
type: string
label:
type: string
placeholder:
type: string
rows:
type: string
type: object
schema.ConnectorInfoResp: schema.ConnectorInfoResp:
properties: properties:
icon: icon:
@ -580,12 +603,11 @@ definitions:
properties: properties:
config_fields: config_fields:
items: items:
$ref: '#/definitions/schema.ConfigFields' $ref: '#/definitions/schema.ConfigField'
type: array type: array
description: description:
type: string type: string
name: name:
description: ConfigFields []plugin.ConfigField `json:"config_fields"`
type: string type: string
slug_name: slug_name:
type: string type: string
@ -600,6 +622,8 @@ definitions:
type: boolean type: boolean
have_config: have_config:
type: boolean type: boolean
link:
type: string
name: name:
type: string type: string
slug_name: slug_name:
@ -920,6 +944,9 @@ definitions:
follow_count: follow_count:
description: follow count description: follow count
type: integer type: integer
have_password:
description: user have password
type: boolean
id: id:
description: user id description: user id
type: string type: string
@ -994,6 +1021,8 @@ definitions:
follow_count: follow_count:
description: follow count description: follow count
type: integer type: integer
have_password:
type: boolean
id: id:
description: user id description: user id
type: string type: string
@ -1485,6 +1514,8 @@ definitions:
type: string type: string
site_seo: site_seo:
$ref: '#/definitions/schema.SiteSeoReq' $ref: '#/definitions/schema.SiteSeoReq'
site_users:
$ref: '#/definitions/schema.SiteUsersResp'
theme: theme:
$ref: '#/definitions/schema.SiteThemeResp' $ref: '#/definitions/schema.SiteThemeResp'
version: version:
@ -1550,6 +1581,12 @@ definitions:
type: object type: object
schema.SiteLoginReq: schema.SiteLoginReq:
properties: properties:
allow_email_domains:
items:
type: string
type: array
allow_email_registrations:
type: boolean
allow_new_registrations: allow_new_registrations:
type: boolean type: boolean
login_required: login_required:
@ -1557,6 +1594,12 @@ definitions:
type: object type: object
schema.SiteLoginResp: schema.SiteLoginResp:
properties: properties:
allow_email_domains:
items:
type: string
type: array
allow_email_registrations:
type: boolean
allow_new_registrations: allow_new_registrations:
type: boolean type: boolean
login_required: login_required:
@ -1609,6 +1652,50 @@ definitions:
$ref: '#/definitions/schema.ThemeOption' $ref: '#/definitions/schema.ThemeOption'
type: array type: array
type: object type: object
schema.SiteUsersReq:
properties:
allow_update_avatar:
type: boolean
allow_update_bio:
type: boolean
allow_update_display_name:
type: boolean
allow_update_location:
type: boolean
allow_update_username:
type: boolean
allow_update_website:
type: boolean
default_avatar:
enum:
- system
- gravatar
type: string
required:
- default_avatar
type: object
schema.SiteUsersResp:
properties:
allow_update_avatar:
type: boolean
allow_update_bio:
type: boolean
allow_update_display_name:
type: boolean
allow_update_location:
type: boolean
allow_update_username:
type: boolean
allow_update_website:
type: boolean
default_avatar:
enum:
- system
- gravatar
type: string
required:
- default_avatar
type: object
schema.SiteWriteReq: schema.SiteWriteReq:
properties: properties:
recommend_tags: recommend_tags:
@ -1687,13 +1774,6 @@ definitions:
value: value:
type: string type: string
type: object type: object
schema.UIWidget:
properties:
placeholder:
type: string
type:
type: string
type: object
schema.UnreviewedRevisionInfoInfo: schema.UnreviewedRevisionInfoInfo:
properties: properties:
content: content:
@ -1971,11 +2051,15 @@ definitions:
schema.UserModifyPassWordRequest: schema.UserModifyPassWordRequest:
properties: properties:
old_pass: old_pass:
description: old password maxLength: 32
minLength: 8
type: string type: string
pass: pass:
description: password maxLength: 32
minLength: 8
type: string type: string
required:
- pass
type: object type: object
schema.UserNoticeSetRequest: schema.UserNoticeSetRequest:
properties: properties:
@ -2881,6 +2965,47 @@ paths:
summary: update site custom css html config summary: update site custom css html config
tags: tags:
- admin - admin
/answer/admin/api/siteinfo/users:
get:
description: get site user config
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/handler.RespBody'
- properties:
data:
$ref: '#/definitions/schema.SiteUsersResp'
type: object
security:
- ApiKeyAuth: []
summary: get site user config
tags:
- admin
put:
description: update site info config about users
parameters:
- description: users info
in: body
name: data
required: true
schema:
$ref: '#/definitions/schema.SiteUsersReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: update site info config about users
tags:
- admin
/answer/admin/api/siteinfo/write: /answer/admin/api/siteinfo/write:
get: get:
description: get site interface description: get site interface

View File

@ -67,7 +67,7 @@ func NewHTTPServer(debug bool,
// plugin routes // plugin routes
pluginAPIRouter.RegisterUnAuthConnectorRouter(mustUnAuthV1) pluginAPIRouter.RegisterUnAuthConnectorRouter(mustUnAuthV1)
pluginAPIRouter.RegisterAuthConnectorRouter(authV1) pluginAPIRouter.RegisterAuthUserConnectorRouter(authV1)
_ = plugin.CallAgent(func(agent plugin.Agent) error { _ = plugin.CallAgent(func(agent plugin.Agent) error {
agent.RegisterUnAuthRouter(unAuthV1) agent.RegisterUnAuthRouter(unAuthV1)

View File

@ -187,6 +187,12 @@ func (uc *UserCenterController) UserCenterUserSettings(ctx *gin.Context) {
handler.HandleResponse(ctx, err, resp) handler.HandleResponse(ctx, err, resp)
} }
// UserCenterAdminFunctionAgent user center admin function agent
func (uc *UserCenterController) UserCenterAdminFunctionAgent(ctx *gin.Context) {
resp, err := uc.userCenterLoginService.UserCenterAdminFunctionAgent(ctx)
handler.HandleResponse(ctx, err, resp)
}
func (uc *UserCenterController) formatRedirectURL(ctx *gin.Context, redirectURL string) string { func (uc *UserCenterController) formatRedirectURL(ctx *gin.Context, redirectURL string) string {
if !strings.Contains(redirectURL, "CALLBACK_URL") { if !strings.Contains(redirectURL, "CALLBACK_URL") {
return redirectURL return redirectURL

View File

@ -355,7 +355,7 @@ func (sc *SiteInfoController) SaveSiteTheme(ctx *gin.Context) {
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Tags admin // @Tags admin
// @Produce json // @Produce json
// @Param data body schema.SiteBrandingReq true "users info" // @Param data body schema.SiteUsersReq true "users info"
// @Success 200 {object} handler.RespBody{} // @Success 200 {object} handler.RespBody{}
// @Router /answer/admin/api/siteinfo/users [put] // @Router /answer/admin/api/siteinfo/users [put]
func (sc *SiteInfoController) UpdateSiteUsers(ctx *gin.Context) { func (sc *SiteInfoController) UpdateSiteUsers(ctx *gin.Context) {

View File

@ -103,7 +103,7 @@ func (a *AnswerAPIRouter) RegisterMustUnAuthAnswerAPIRouter(r *gin.RouterGroup)
// user // user
r.GET("/user/info", a.userController.GetUserInfoByUserID) r.GET("/user/info", a.userController.GetUserInfoByUserID)
routerGroup := r.Group("", middleware.BanAPIWhenUserCenterEnabled) routerGroup := r.Group("", middleware.BanAPIWhenUserCenterEnabled)
routerGroup.POST("/user/login/email", a.userController.UserEmailLogin) r.POST("/user/login/email", a.userController.UserEmailLogin)
routerGroup.POST("/user/register/email", a.userController.UserRegisterByEmail) routerGroup.POST("/user/register/email", a.userController.UserRegisterByEmail)
routerGroup.GET("/user/register/captcha", a.userController.UserRegisterCaptcha) routerGroup.GET("/user/register/captcha", a.userController.UserRegisterCaptcha)
routerGroup.POST("/user/email/verification", a.userController.UserVerifyEmail) routerGroup.POST("/user/email/verification", a.userController.UserVerifyEmail)

View File

@ -37,10 +37,14 @@ func (pr *PluginAPIRouter) RegisterUnAuthConnectorRouter(r *gin.RouterGroup) {
r.GET("/user-center/sign-up/callback", pr.userCenterController.UserCenterSignUpCallback) r.GET("/user-center/sign-up/callback", pr.userCenterController.UserCenterSignUpCallback)
} }
func (pr *PluginAPIRouter) RegisterAuthConnectorRouter(r *gin.RouterGroup) { func (pr *PluginAPIRouter) RegisterAuthUserConnectorRouter(r *gin.RouterGroup) {
connectorController := pr.connectorController connectorController := pr.connectorController
r.GET("/connector/user/info", connectorController.ConnectorsUserInfo) r.GET("/connector/user/info", connectorController.ConnectorsUserInfo)
r.DELETE("/connector/user/unbinding", connectorController.ExternalLoginUnbinding) r.DELETE("/connector/user/unbinding", connectorController.ExternalLoginUnbinding)
r.GET("/user-center/user/settings", pr.userCenterController.UserCenterUserSettings) r.GET("/user-center/user/settings", pr.userCenterController.UserCenterUserSettings)
} }
func (pr *PluginAPIRouter) RegisterAuthAdminConnectorRouter(r *gin.RouterGroup) {
r.GET("/user-center/agent", pr.userCenterController.UserCenterAdminFunctionAgent)
}

View File

@ -67,6 +67,10 @@ type UserCenterUserSettingsResp struct {
AccountSettingAgent UserSettingAgent `json:"account_setting_agent"` AccountSettingAgent UserSettingAgent `json:"account_setting_agent"`
} }
type UserCenterAdminFunctionAgentResp struct {
RoleAgentEnabled bool `json:"role_agent_enabled"`
}
type UserSettingAgent struct { type UserSettingAgent struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
RedirectURL string `json:"redirect_url"` RedirectURL string `json:"redirect_url"`

View File

@ -195,6 +195,18 @@ func (us *UserCenterLoginService) UserCenterUserSettings(ctx context.Context, us
return resp, nil return resp, nil
} }
func (us *UserCenterLoginService) UserCenterAdminFunctionAgent(ctx context.Context) (
resp *schema.UserCenterAdminFunctionAgentResp, err error) {
resp = &schema.UserCenterAdminFunctionAgentResp{}
userCenter, ok := plugin.GetUserCenter()
if !ok {
return
}
desc := userCenter.Description()
resp.RoleAgentEnabled = desc.RoleAgentEnabled
return resp, nil
}
func (us *UserCenterLoginService) UserCenterPersonalBranding(ctx context.Context, username string) ( func (us *UserCenterLoginService) UserCenterPersonalBranding(ctx context.Context, username string) (
resp *schema.UserCenterPersonalBranding, err error) { resp *schema.UserCenterPersonalBranding, err error) {
resp = &schema.UserCenterPersonalBranding{ resp = &schema.UserCenterPersonalBranding{

View File

@ -29,6 +29,7 @@ type UserCenterDesc struct {
LoginRedirectURL string `json:"login_redirect_url"` LoginRedirectURL string `json:"login_redirect_url"`
SignUpRedirectURL string `json:"sign_up_redirect_url"` SignUpRedirectURL string `json:"sign_up_redirect_url"`
RankAgentEnabled bool `json:"rank_agent_enabled"` RankAgentEnabled bool `json:"rank_agent_enabled"`
RoleAgentEnabled bool `json:"role_agent_enabled"`
MustAuthEmailEnabled bool `json:"must_auth_email_enabled"` MustAuthEmailEnabled bool `json:"must_auth_email_enabled"`
} }