Skip to content

Commit

Permalink
fix: 修复统一密码未更新时未返回报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Penryn committed Dec 17, 2024
1 parent 7de3a6e commit 689ddb0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
11 changes: 8 additions & 3 deletions app/controller/controllerHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ func ErrorHandle(context *gin.Context, err error) {
case errors.ERR_WRONG_PASSWORD:
{
exp = errors.WrongPassword
break
}
case errors.ERR_WRONG_Captcha:
{
exp = errors.CaptchaFailed
break
}
case errors.ERR_Session_Expired:
{
exp = errors.SessionExpired
break
}
case errors.ERR_OAUTH_ERROR:
{
exp = errors.OAuthNotUpdate
}
default:
{
exp = errors.UnKnown
}
}

Expand Down
1 change: 1 addition & 0 deletions app/errors/funnelErrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ var ERR_INVALID_ARGS = errors.New("invalid args")
var ERR_SESSION_NOT_EXIST = errors.New("ERR_SESSION_NOT_EXIST")
var ERR_SESSION_EXPIRES = errors.New("ERR_SESSION_EXPIRES")
var ERR_OAUTH_ERROR = errors.New("ERR_OAUTH_ERROR")
var ERR_UNKNOWN = errors.New("ERR_UNKNOWN")
1 change: 1 addition & 0 deletions app/errors/httpResponseErrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ var WrongPassword = HttpResponseError{412, "密码错误"}
var CaptchaFailed = HttpResponseError{413, "验证码错误"}
var SessionExpired = HttpResponseError{414, "缓存过期"}
var OauthError = HttpResponseError{415, "缓存过期"}
var OAuthNotUpdate = HttpResponseError{416, "统一密码未更新"}
2 changes: 1 addition & 1 deletion app/service/zfService/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func loginByOauth(username string, password string) (*model.User, error) {
}
getRedirectUrl2, err := f.GetRedirect(getRedirectUrl1.String())
if err != nil {
return nil, err
return nil, errors.ERR_OAUTH_ERROR
}
getRedirectUrl3, err := f.GetRedirect(getRedirectUrl2.String())
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions app/utils/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fetch

import (
"crypto/tls"
"fmt"
errors2 "funnel/app/errors"
"io"
"net/http"
Expand Down Expand Up @@ -56,7 +55,7 @@ func (f *Fetch) GetRedirect(url string) (*url.URL, error) {
return nil, err
}
if response.StatusCode != 302 {
return nil, errors2.ERR_OAUTH_ERROR
return nil, errors2.ERR_UNKNOWN
}
location, err := response.Location()
if err != nil {
Expand Down Expand Up @@ -107,8 +106,6 @@ func (f *Fetch) PostFormRedirect(url string, requestData url.Values) (*url.URL,
return nil, err
}
if response.StatusCode != 302 {
fmt.Println(url)
fmt.Println(response.StatusCode)
return nil, errors2.ERR_WRONG_PASSWORD
}
f.Cookie = cookieMerge(f.Cookie, response.Cookies())
Expand Down

0 comments on commit 689ddb0

Please sign in to comment.