diff --git a/controller/user.go b/controller/user.go index 51328d783b..b6241d368f 100644 --- a/controller/user.go +++ b/controller/user.go @@ -467,6 +467,13 @@ func CreateUser(c *gin.Context) { }) return } + if err := common.Validate.Struct(&user); err != nil { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "输入不合法 " + err.Error(), + }) + return + } if user.DisplayName == "" { user.DisplayName = user.Username } diff --git a/web/src/components/UsersTable.js b/web/src/components/UsersTable.js index 31acaf9246..1fdd892322 100644 --- a/web/src/components/UsersTable.js +++ b/web/src/components/UsersTable.js @@ -4,6 +4,7 @@ import { Link } from 'react-router-dom'; import { API, showError, showSuccess } from '../helpers'; import { ITEMS_PER_PAGE } from '../constants'; +import { renderText } from '../helpers/render'; function renderRole(role) { switch (role) { @@ -64,7 +65,7 @@ const UsersTable = () => { (async () => { const res = await API.post('/api/user/manage', { username, - action, + action }); const { success, message } = res.data; if (success) { @@ -161,18 +162,18 @@ const UsersTable = () => {