use revel 1.0.0 && go module
This commit is contained in:
@ -23,18 +23,18 @@ type ApiBaseContrller struct {
|
||||
|
||||
// 得到token, 这个token是在AuthInterceptor设到Session中的
|
||||
func (c ApiBaseContrller) getToken() string {
|
||||
return c.Session["_token"]
|
||||
return c.GetSession("_token")
|
||||
}
|
||||
|
||||
// userId
|
||||
// _userId是在AuthInterceptor设置的
|
||||
func (c ApiBaseContrller) getUserId() string {
|
||||
return c.Session["_userId"]
|
||||
return c.GetSession("_userId")
|
||||
}
|
||||
|
||||
// 得到用户信息
|
||||
func (c ApiBaseContrller) getUserInfo() info.User {
|
||||
userId := c.Session["_userId"]
|
||||
userId := c.GetSession("_userId")
|
||||
if userId == "" {
|
||||
return info.User{}
|
||||
}
|
||||
|
@ -90,7 +90,10 @@ func AuthInterceptor(c *revel.Controller) revel.Result {
|
||||
if noToken && userId == "" {
|
||||
// 从session中获取, api/file/getImage, api/file/getAttach, api/file/getAllAttach
|
||||
// 客户端
|
||||
userId, _ = c.Session["UserId"]
|
||||
userIdI, _ := c.Session["UserId"]
|
||||
if userIdI != nil {
|
||||
userId = userIdI.(string)
|
||||
}
|
||||
}
|
||||
c.Session["_userId"] = userId
|
||||
|
||||
|
Reference in New Issue
Block a user