Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复统一密码未更新时未返回报错的问题 #25

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_NOT_UPDATE:
{
exp = errors.OAuthNotUpdate
}
default:
{
exp = errors.UnKnown
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/errors/funnelErrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ var ERR_WRONG_Captcha = errors.New("ERR_WRONG_Captcha")
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_OAUTH_NOT_UPDATE = errors.New("ERR_OAUTH_NOT_UPDATE")
var ERR_UNKNOWN_ERROR = 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_NOT_UPDATE
}
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_ERROR
}
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
Loading