feat: add employee role and block backend login
This commit is contained in:
@@ -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
@@ -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 管理员重置用户密码
|
||||
|
||||
Reference in New Issue
Block a user