|
@@ -2,12 +2,10 @@ package User
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
- "fmt"
|
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
"github.com/suyuan32/simple-admin-common/utils/pointy"
|
|
|
"github.com/suyuan32/simple-admin-core/rpc/types/core"
|
|
|
"github.com/zeromicro/go-zero/core/errorx"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
"wechat-api/internal/utils"
|
|
|
"wechat-api/internal/utils/jwt"
|
|
@@ -45,14 +43,8 @@ func (l *DoGptsUserLoginLogic) DoGptsUserLogin(req *types.GptsUserLoginReq) (res
|
|
|
return nil, errorx.NewCodeInvalidArgumentError("login.wrongUsernameOrPassword")
|
|
|
}
|
|
|
|
|
|
- department, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{
|
|
|
- Id: *user.DepartmentId,
|
|
|
- })
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- fmt.Printf("department=%v\n", department)
|
|
|
- if *department.Name != "前台用户" {
|
|
|
+ valid := utils.CheckGptLogin(user.RoleIds)
|
|
|
+ if !valid {
|
|
|
return nil, errorx.NewInvalidArgumentError("用户不允许登陆")
|
|
|
}
|
|
|
|
|
@@ -61,8 +53,6 @@ func (l *DoGptsUserLoginLogic) DoGptsUserLogin(req *types.GptsUserLoginReq) (res
|
|
|
time.Now().Unix(),
|
|
|
l.svcCtx.Config.Auth.AccessExpire,
|
|
|
jwt.WithOption("userId", user.Id),
|
|
|
- jwt.WithOption("roleId", strings.Join(user.RoleCodes, ",")),
|
|
|
- jwt.WithOption("deptId", user.DepartmentId),
|
|
|
)
|
|
|
if err != nil {
|
|
|
return nil, err
|