feat: add employee role and block backend login

This commit is contained in:
Frudrax Cheng
2026-05-28 09:30:31 +08:00
parent 0beb912e0c
commit f394d3a8bd
2 changed files with 6 additions and 2 deletions
+4
View File
@@ -43,6 +43,10 @@ func (c *AuthController) Login(ctx *gin.Context) {
ErrorResponse(ctx, http.StatusUnauthorized, err.Error())
return
}
if user.Role == "employee" {
ErrorResponse(ctx, http.StatusForbidden, "员工账号无后台登录权限")
return
}
token, err := c.authService.GenerateToken(user)
if err != nil {
+2 -2
View File
@@ -80,14 +80,14 @@ type CreateUserDTO struct {
Password string `json:"password" validate:"required,min=6"`
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"omitempty,email"`
Role string `json:"role" validate:"required,oneof=admin technician user"`
Role string `json:"role" validate:"required,oneof=admin technician employee user"`
}
// UpdateUserDTO 管理员更新用户信息请求
type UpdateUserDTO struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty" validate:"omitempty,email"`
Role string `json:"role,omitempty" validate:"omitempty,oneof=admin technician user"`
Role string `json:"role,omitempty" validate:"omitempty,oneof=admin technician employee user"`
}
// AdminResetPasswordDTO 管理员重置用户密码