|
@@ -108,7 +108,7 @@ func (la *LightAuth) Login(c *entitys.CtrlContext) {
|
|
|
if session != nil {
|
|
if session != nil {
|
|
|
ip := RemoteIp(c.Ctx.Request)
|
|
ip := RemoteIp(c.Ctx.Request)
|
|
|
sql := "insert into log_sys_login (user_id,account,ip_addr,login_time,del_flag,login_type,user_name,resource_type) values (?, ?,?,?,?,?,?,?)"
|
|
sql := "insert into log_sys_login (user_id,account,ip_addr,login_time,del_flag,login_type,user_name,resource_type) values (?, ?,?,?,?,?,?,?)"
|
|
|
- _, err = session.Exec(sql, user.Id, user.LoginId, ip, sysmodel.NowLocal().Value(), 0, 0, user.Name,"E-school账号")
|
|
|
|
|
|
|
+ _, err = session.Exec(sql, user.Id, user.LoginId, ip, sysmodel.NowLocal().Value(), 0, 0, user.Name, "E-school账号")
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
|
return
|
|
return
|
|
@@ -134,23 +134,23 @@ func (la *LightAuth) Logout(c *entitys.CtrlContext) {
|
|
|
if session != nil && tokenInfo != nil {
|
|
if session != nil && tokenInfo != nil {
|
|
|
_, err := c.PlatformDbEngine.Table(user.TableName()).Where("login_id = ?", tokenInfo.LoginID).Get(user)
|
|
_, err := c.PlatformDbEngine.Table(user.TableName()).Where("login_id = ?", tokenInfo.LoginID).Get(user)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
|
|
|
|
|
+ c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), 111})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
ip := RemoteIp(c.Ctx.Request)
|
|
ip := RemoteIp(c.Ctx.Request)
|
|
|
var resource_type string
|
|
var resource_type string
|
|
|
- res,err:=session.Where("login_id = ?", user.LoginId).Query().List()
|
|
|
|
|
- if err!=nil{
|
|
|
|
|
- c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
|
|
|
|
|
+ res, err := session.SQL("SELECT `resource_type` FROM `log_sys_login` WHERE (account = ?) ORDER BY id desc LIMIT 1", tokenInfo.LoginID).Query().List()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), 2222})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if len(res)>0{
|
|
|
|
|
- resource_type = res[0]["resource_type"]
|
|
|
|
|
|
|
+ if len(res) > 0 {
|
|
|
|
|
+ resource_type, _ = res[0]["resource_type"].(string)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sql := "insert into log_sys_login (user_id,account,ip_addr,login_time,del_flag,login_type,user_name,resource_type) values (?, ?,?,?,?,?,?,?)"
|
|
sql := "insert into log_sys_login (user_id,account,ip_addr,login_time,del_flag,login_type,user_name,resource_type) values (?, ?,?,?,?,?,?,?)"
|
|
|
- if
|
|
|
|
|
- _, err = session.Exec(sql, user.Id, user.LoginId, ip, sysmodel.NowLocal().Value(), 0, 1, user.Name,resource_type)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ _, err = session.Exec(sql, user.Id, user.LoginId, ip, sysmodel.NowLocal().Value(), 0, 1, user.Name, resource_type)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
c.Ctx.JSON(200, sysmodel.SysReturn{400, err.Error(), nil})
|
|
|
return
|
|
return
|