Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
fix: Fix the modified password function and do authentication processing
Browse files Browse the repository at this point in the history
  • Loading branch information
PBK-B committed Sep 1, 2021
1 parent 65a707f commit be0f60a
Show file tree
Hide file tree
Showing 7 changed files with 774 additions and 485 deletions.
11 changes: 10 additions & 1 deletion controllers/apis/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (c *UsersController) ApiUpStatusUser() {

func (c *UsersController) ApiUpdateUser() {
// 要求登陆助理函数
userAssistant(&c.Controller)
_, me, _ := userAssistant(&c.Controller)

u_id, _ := c.GetInt("id", 0)
u_password := c.GetString("password")
Expand All @@ -163,6 +163,13 @@ func (c *UsersController) ApiUpdateUser() {
return
}

// TODO: 目前简单判断 ID 为 1 的用户为超级管理员
if me.Id != 1 && me.Id != u_id {
callBackResult(&c.Controller, 403, "权限不足", nil)
c.Finish()
return
}

user, err := models.GetUserById(u_id)

if user == nil || err != nil {
Expand All @@ -174,6 +181,8 @@ func (c *UsersController) ApiUpdateUser() {
// TODO: Bin BY 这里应该还可以做判断用户名和密码是否合法
user.Password = helper.StringToMd5(u_password)

err = models.UpdateUsersById(user)

if err != nil {
callBackResult(&c.Controller, 200, "出错啦,"+err.Error(), nil)
c.Finish()
Expand Down
222 changes: 217 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 60 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
{
"name": "mirai-class-notice",
"version": "1.0.0",
"description": "🥳 这是一款基于 mirai 的班级 QQ 群课程通知机器人,拥有简单的 web 管理页面,尽量实现一键安装简易操作等功能。",
"main": "src/index.js",
"directories": {
"test": "tests"
},
"scripts": {
"watch": "npx mix watch",
"debug": "npx mix",
"build": "npx mix --production"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PBK-B/mirai-class-notice.git"
},
"keywords": [
"mirai-web"
],
"author": "PBK-B",
"license": "ISC",
"bugs": {
"url": "https://github.com/PBK-B/mirai-class-notice/issues"
},
"homepage": "https://github.com/PBK-B/mirai-class-notice#readme",
"devDependencies": {
"@babel/preset-react": "^7.12.13",
"all-contributors-cli": "^6.20.0",
"laravel-mix": "^6.0.13",
"less": "^2.7.3",
"less-loader": "^4.1.0",
"postcss": "^8.2.8",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.8",
"sass-loader": "^10.1.1"
},
"dependencies": {
"axios": "^0.21.1",
"axios-hooks": "^2.4.1",
"js-md5": "^0.7.3",
"qrcode": "^1.4.4",
"rsuite": "^4.9.2"
}
"name": "mirai-class-notice",
"version": "1.0.0",
"description": "🥳 这是一款基于 mirai 的班级 QQ 群课程通知机器人,拥有简单的 web 管理页面,尽量实现一键安装简易操作等功能。",
"main": "src/index.js",
"directories": {
"test": "tests"
},
"scripts": {
"watch": "npx mix watch",
"debug": "npx mix",
"build": "npx mix --production",
"pack": "npm run build && bee pack -exs=.:node_modules:src:logs:conf/app.conf:.git:package-lock.json:package.json:helper:models:routers:tests:main.go",
"pack-windows": "npm run build && bee pack -exs=.:node_modules:src:logs:conf/app.conf:.git:package-lock.json:package.json:helper:models:routers:tests:main.go -be='GOOS=windows' ",
"pack-linux": "npm run build && bee pack -exs=.:node_modules:src:logs:conf/app.conf:.git:package-lock.json:package.json:helper:models:routers:tests:main.go -be='GOOS=linux'"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PBK-B/mirai-class-notice.git"
},
"keywords": [
"mirai-web"
],
"author": "PBK-B",
"license": "ISC",
"bugs": {
"url": "https://github.com/PBK-B/mirai-class-notice/issues"
},
"homepage": "https://github.com/PBK-B/mirai-class-notice#readme",
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/preset-react": "^7.12.13",
"all-contributors-cli": "^6.20.0",
"laravel-mix": "^6.0.13",
"less": "^2.7.3",
"less-loader": "^4.1.0",
"mobx": "^6.3.3",
"mobx-react": "^7.2.0",
"postcss": "^8.2.8",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.8",
"sass-loader": "^10.1.1"
},
"dependencies": {
"axios": "^0.21.1",
"axios-hooks": "^2.4.1",
"js-md5": "^0.7.3",
"qrcode": "^1.4.4",
"rsuite": "^4.9.2"
},
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
}
Loading

0 comments on commit be0f60a

Please sign in to comment.