|
|
@ -2,6 +2,7 @@ package system |
|
|
|
|
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request" |
|
|
@ -39,6 +40,10 @@ func (userService *UserService) Register(u system.SysUser) (err error, userInter |
|
|
|
//@return: err error, userInter *model.SysUser
|
|
|
|
|
|
|
|
func (userService *UserService) Login(u *system.SysUser) (err error, userInter *system.SysUser) { |
|
|
|
if nil == global.GVA_DB { |
|
|
|
return fmt.Errorf("db not init"), nil |
|
|
|
} |
|
|
|
|
|
|
|
var user system.SysUser |
|
|
|
u.Password = utils.MD5V([]byte(u.Password)) |
|
|
|
err = global.GVA_DB.Where("username = ? AND password = ?", u.Username, u.Password).Preload("Authorities").Preload("Authority").First(&user).Error |
|
|
|