Skip to content

Commit 796005f

Browse files
committed
fix: unable to recover user from trash or permanently delete them #552
1 parent 53eac76 commit 796005f

File tree

5 files changed

+475
-482
lines changed

5 files changed

+475
-482
lines changed

api/user/router.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package user
22

33
import (
4-
"github.com/gin-gonic/gin"
4+
"github.com/gin-gonic/gin"
55
)
66

77
func InitAuthRouter(r *gin.RouterGroup) {
@@ -18,6 +18,7 @@ func InitManageUserRouter(r *gin.RouterGroup) {
1818
r.POST("user", AddUser)
1919
r.POST("user/:id", EditUser)
2020
r.DELETE("user/:id", DeleteUser)
21+
r.PATCH("user/:id", RecoverUser)
2122
}
2223

2324
func InitUserRouter(r *gin.RouterGroup) {
@@ -26,6 +27,6 @@ func InitUserRouter(r *gin.RouterGroup) {
2627
r.POST("/otp_enroll", EnrollTOTP)
2728
r.POST("/otp_reset", ResetOTP)
2829

29-
r.GET("/otp_secure_session_status", SecureSessionStatus)
30+
r.GET("/otp_secure_session_status", SecureSessionStatus)
3031
r.POST("/otp_secure_session", StartSecure2FASession)
3132
}

api/user/user.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,15 @@ func EditUser(c *gin.Context) {
118118

119119
func DeleteUser(c *gin.Context) {
120120
id := cast.ToInt(c.Param("id"))
121-
122121
if cast.ToInt(id) == 1 {
123122
c.JSON(http.StatusNotAcceptable, gin.H{
124123
"message": "Prohibit deleting the default user",
125124
})
126125
return
127126
}
127+
cosy.Core[model.Auth](c).Destroy()
128+
}
128129

129-
u := query.Auth
130-
err := u.DeleteByID(id)
131-
if err != nil {
132-
api.ErrHandler(c, err)
133-
return
134-
}
135-
c.JSON(http.StatusNoContent, nil)
130+
func RecoverUser(c *gin.Context) {
131+
cosy.Core[model.Auth](c).Recover()
136132
}

app/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
"@0xjacky/vue-github-button": "^3.1.1",
1515
"@ant-design/icons-vue": "^7.0.1",
1616
"@formkit/auto-animate": "^0.8.2",
17-
"@vue/reactivity": "^3.4.38",
18-
"@vue/shared": "^3.4.38",
17+
"@vue/reactivity": "^3.5.5",
18+
"@vue/shared": "^3.5.5",
1919
"@vueuse/components": "^11.0.3",
2020
"@vueuse/core": "^11.0.3",
2121
"@vueuse/integrations": "^11.0.3",
2222
"@xterm/addon-attach": "^0.11.0",
2323
"@xterm/addon-fit": "^0.10.0",
2424
"@xterm/xterm": "^5.5.0",
25-
"ant-design-vue": "^4.2.3",
25+
"ant-design-vue": "^4.2.4",
2626
"apexcharts": "^3.53.0",
2727
"axios": "^1.7.7",
2828
"dayjs": "^1.11.13",
@@ -35,11 +35,11 @@
3535
"reconnecting-websocket": "^4.4.0",
3636
"sortablejs": "^1.15.3",
3737
"universal-cookie": "^7.2.0",
38-
"vite-plugin-build-id": "^0.3.5",
39-
"vue": "^3.4.38",
40-
"vue-router": "^4.4.3",
38+
"vite-plugin-build-id": "^0.3.6",
39+
"vue": "^3.5.5",
40+
"vue-router": "^4.4.5",
4141
"vue3-ace-editor": "2.2.4",
42-
"vue3-apexcharts": "1.6.0",
42+
"vue3-apexcharts": "1.5.3",
4343
"vue3-gettext": "3.0.0-beta.5",
4444
"vue3-otp-input": "^0.5.21",
4545
"vuedraggable": "^4.1.0"
@@ -53,27 +53,27 @@
5353
"@typescript-eslint/parser": "^6.21.0",
5454
"@vitejs/plugin-vue": "^5.1.3",
5555
"@vitejs/plugin-vue-jsx": "^4.0.1",
56-
"@vue/compiler-sfc": "^3.4.38",
56+
"@vue/compiler-sfc": "^3.5.5",
5757
"@vue/tsconfig": "^0.5.1",
5858
"ace-builds": "^1.36.2",
5959
"autoprefixer": "^10.4.20",
6060
"eslint": "^8.57.0",
6161
"eslint-import-resolver-alias": "^1.1.2",
6262
"eslint-import-resolver-typescript": "^3.6.3",
63-
"eslint-plugin-import": "^2.29.1",
63+
"eslint-plugin-import": "^2.30.0",
6464
"eslint-plugin-regex": "^1.10.0",
6565
"eslint-plugin-sonarjs": "^0.23.0",
66-
"eslint-plugin-vue": "^9.27.0",
66+
"eslint-plugin-vue": "^9.28.0",
6767
"less": "^4.2.0",
68-
"postcss": "^8.4.44",
69-
"tailwindcss": "^3.4.10",
68+
"postcss": "^8.4.47",
69+
"tailwindcss": "^3.4.11",
7070
"typescript": "5.5.4",
71-
"unplugin-auto-import": "^0.18.2",
71+
"unplugin-auto-import": "^0.18.3",
7272
"unplugin-vue-components": "^0.27.4",
73-
"unplugin-vue-define-options": "^1.4.9",
74-
"vite": "^5.4.2",
73+
"unplugin-vue-define-options": "^1.5.1",
74+
"vite": "^5.4.5",
7575
"vite-svg-loader": "^5.1.0",
76-
"vue-tsc": "^2.1.4"
76+
"vue-tsc": "^2.1.6"
7777
},
7878
"packageManager": "[email protected]"
7979
}

0 commit comments

Comments
 (0)