mirror of https://github.com/bjdgyc/anylink.git
优化代码
This commit is contained in:
parent
bd6ee0b140
commit
96fd114c25
|
@ -172,6 +172,8 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
body, err := io.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
base.Error(err)
|
||||||
|
SessStore.DeleteAuthSession(sessionID)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -181,6 +183,7 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
|
||||||
err = xml.Unmarshal(body, &cr)
|
err = xml.Unmarshal(body, &cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error(err)
|
base.Error(err)
|
||||||
|
SessStore.DeleteAuthSession(sessionID)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -193,6 +196,7 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
|
||||||
// 动态码错误
|
// 动态码错误
|
||||||
if !dbdata.CheckOtp(username, otp, otpSecret) {
|
if !dbdata.CheckOtp(username, otp, otpSecret) {
|
||||||
if sessionData.AddOtpErrCount(1) > maxOtpErrCount {
|
if sessionData.AddOtpErrCount(1) > maxOtpErrCount {
|
||||||
|
SessStore.DeleteAuthSession(sessionID)
|
||||||
http.Error(w, "TooManyError, please login again", http.StatusBadRequest)
|
http.Error(w, "TooManyError, please login again", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue