提交 d5c354da 编写于 作者: K K

chore: fix db connector nil pointer dereference

上级 3f8bbdf1
......@@ -16,7 +16,6 @@ require (
github.com/go-redis/redis/v8 v8.11.0
github.com/go-sql-driver/mysql v1.5.0
github.com/gookit/color v1.3.1
github.com/jackc/pgx/v4 v4.7.1
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
github.com/mojocn/base64Captcha v1.3.1
github.com/natefinch/lumberjack v2.0.0+incompatible
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册