正在显示
4 个修改的文件
包含
10 行增加
和
5 行删除
@@ -169,6 +169,9 @@ func CheckToken(ctx *context.Context) (result bool) { | @@ -169,6 +169,9 @@ func CheckToken(ctx *context.Context) (result bool) { | ||
169 | var ( | 169 | var ( |
170 | msg *protocol.ResponseMessage | 170 | msg *protocol.ResponseMessage |
171 | ) | 171 | ) |
172 | + if strings.HasSuffix(ctx.Request.RequestURI,"login"){ | ||
173 | + return true | ||
174 | + } | ||
172 | result = true | 175 | result = true |
173 | defer func() { | 176 | defer func() { |
174 | if msg != nil { | 177 | if msg != nil { |
@@ -17,7 +17,7 @@ type Chance struct { | @@ -17,7 +17,7 @@ type Chance struct { | ||
17 | ChanceTypeId int `orm:"column(chance_type_id)" description:"表cfg_chance_type.id 机会类型 1:产品 2:渠道 3.客户 4.区域 5.其他 "` | 17 | ChanceTypeId int `orm:"column(chance_type_id)" description:"表cfg_chance_type.id 机会类型 1:产品 2:渠道 3.客户 4.区域 5.其他 "` |
18 | Content string `orm:"column(content)" description:"内容"` | 18 | Content string `orm:"column(content)" description:"内容"` |
19 | CommentTotal int `orm:"column(comment_total)" description:"评论总数"` | 19 | CommentTotal int `orm:"column(comment_total)" description:"评论总数"` |
20 | - FavoriteTotal int `orm:"column(favorite_total)" description:"点赞总数"` | 20 | + ZanTotal int `orm:"column(zan_total)" description:"点赞总数"` |
21 | ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待审核 1:被退回 2:已通过 3:草稿箱"` | 21 | ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待审核 1:被退回 2:已通过 3:草稿箱"` |
22 | EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` | 22 | EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` |
23 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | 23 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` |
@@ -158,7 +158,7 @@ func DeleteUserAuth(id int) (err error) { | @@ -158,7 +158,7 @@ func DeleteUserAuth(id int) (err error) { | ||
158 | 158 | ||
159 | func GetUserByAuthCode(authCode string) (v *UserAuth, err error) { | 159 | func GetUserByAuthCode(authCode string) (v *UserAuth, err error) { |
160 | o := orm.NewOrm() | 160 | o := orm.NewOrm() |
161 | - sql := "select * from user_auth where auth_code=? and auth_exp >= Now()" | 161 | + sql := "select * from user_auth where auth_code=? and auth_code_exp >= Now()" |
162 | if err = o.Raw(sql, authCode).QueryRow(&v); err == nil { | 162 | if err = o.Raw(sql, authCode).QueryRow(&v); err == nil { |
163 | return v, nil | 163 | return v, nil |
164 | } | 164 | } |
@@ -167,7 +167,7 @@ func GetUserByAuthCode(authCode string) (v *UserAuth, err error) { | @@ -167,7 +167,7 @@ func GetUserByAuthCode(authCode string) (v *UserAuth, err error) { | ||
167 | 167 | ||
168 | func GetUserAuthByRefreshToken(refreshToken string) (v *UserAuth, err error) { | 168 | func GetUserAuthByRefreshToken(refreshToken string) (v *UserAuth, err error) { |
169 | o := orm.NewOrm() | 169 | o := orm.NewOrm() |
170 | - sql := "select * from user_auth where refresh_token=? and auth_exp >= Now()" // TODO: and enabled = 1 | 170 | + sql := "select * from user_auth where refresh_token=? and refresh_token_exp >= Now()" // TODO: and enabled = 1 |
171 | if err = o.Raw(sql, refreshToken).QueryRow(&v); err == nil { | 171 | if err = o.Raw(sql, refreshToken).QueryRow(&v); err == nil { |
172 | return v, nil | 172 | return v, nil |
173 | } | 173 | } |
@@ -176,7 +176,7 @@ func GetUserAuthByRefreshToken(refreshToken string) (v *UserAuth, err error) { | @@ -176,7 +176,7 @@ func GetUserAuthByRefreshToken(refreshToken string) (v *UserAuth, err error) { | ||
176 | 176 | ||
177 | func GetUserAuthByToken(refreshToken string) (v *UserAuth, err error) { | 177 | func GetUserAuthByToken(refreshToken string) (v *UserAuth, err error) { |
178 | o := orm.NewOrm() | 178 | o := orm.NewOrm() |
179 | - sql := "select * from user_auth where refresh_token=? and auth_exp >= Now()" // TODO: and enabled = 1 | 179 | + sql := "select * from user_auth where access_token=? and access_token_exp >= Now()" // TODO: and enabled = 1 |
180 | if err = o.Raw(sql, refreshToken).QueryRow(&v); err == nil { | 180 | if err = o.Raw(sql, refreshToken).QueryRow(&v); err == nil { |
181 | return v, nil | 181 | return v, nil |
182 | } | 182 | } |
@@ -117,7 +117,7 @@ Success: | @@ -117,7 +117,7 @@ Success: | ||
117 | if user.CsAccount == 0 { | 117 | if user.CsAccount == 0 { |
118 | user.CsAccount = imGetRandomCSAccount() | 118 | user.CsAccount = imGetRandomCSAccount() |
119 | } | 119 | } |
120 | - userAuth.AccessTokenExp = time.Now().Add(time.Second * protocol.TokenExpire) | 120 | + userAuth.AuthCodeExp = time.Now().Add(time.Second * protocol.TokenExpire) |
121 | if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { | 121 | if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { |
122 | return | 122 | return |
123 | } | 123 | } |
@@ -149,6 +149,8 @@ func (s *AuthService) AccessToken(request *protocol.AccessTokenRequest) (rsp *pr | @@ -149,6 +149,8 @@ func (s *AuthService) AccessToken(request *protocol.AccessTokenRequest) (rsp *pr | ||
149 | } | 149 | } |
150 | userAuth.AccessToken = uid.NewV1().StringNoDash() | 150 | userAuth.AccessToken = uid.NewV1().StringNoDash() |
151 | userAuth.RefreshToken = uid.NewV1().StringNoDash() | 151 | userAuth.RefreshToken = uid.NewV1().StringNoDash() |
152 | + userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire*time.Second) | ||
153 | + userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire*time.Second) | ||
152 | if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { | 154 | if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { |
153 | log.Error(err) | 155 | log.Error(err) |
154 | return | 156 | return |
-
请 注册 或 登录 后发表评论