-
Notifications
You must be signed in to change notification settings - Fork 3
/
auth.go
62 lines (58 loc) · 1.58 KB
/
auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package backend
import (
"github.com/MQEnergy/go-skeleton/internal/app/service"
"github.com/MQEnergy/go-skeleton/internal/request/user"
"github.com/gofiber/fiber/v2"
)
type AuthService struct {
service.Service
}
var Auth = &AuthService{}
// Login
// @Description: 登录
// @receiver s
// @param reqParams
// @return interface{}
// @return error
// @author cx
func (s *AuthService) Login(reqParams *user.LoginReq) (fiber.Map, error) {
//var (
// isSuper = 0 // 是否超级管理员 1:是 0:不是
// u = dao.Admin
// err error
// adminInfo *model.Admin
//)
//adminInfo, err = u.GetByAccount(reqParams.Account)
//if err != nil {
// return nil, errors.New("账号或密码不正确")
//}
//if adminInfo.Status != 1 {
// return nil, errors.New("用户已锁定,无法登录")
//}
//if adminInfo.Password != helper.GeneratePasswordHash(reqParams.Password, adminInfo.Salt) {
// return nil, errors.New("账号或密码不正确")
//}
//token, err := jwtauth.New(vars.Config).WithClaims(jwt.MapClaims{
// "id": adminInfo.ID,
// "uuid": adminInfo.UUID,
// "role_ids": adminInfo.RoleIds,
//}).GenerateToken()
//if err != nil {
// return nil, errors.New("登录失败")
//}
//if helper.InAnySlice(strings.Split(adminInfo.RoleIds, ","), "1") {
// isSuper = 1
//}
//return fiber.Map{
// "token": token,
// "info": fiber.Map{
// "id": adminInfo.ID,
// "uuid": adminInfo.UUID,
// "account": adminInfo.Account,
// "avatar": adminInfo.Avatar,
// "role_ids": adminInfo.RoleIds,
// "is_super": isSuper,
// },
//}, nil
return nil, nil
}