Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgyc committed Oct 25, 2024
1 parent bd6ee0b commit 96fd114
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/handler/link_auth_otp.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {

body, err := io.ReadAll(r.Body)
if err != nil {
base.Error(err)
SessStore.DeleteAuthSession(sessionID)
w.WriteHeader(http.StatusBadRequest)
return
}
Expand All @@ -181,6 +183,7 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
err = xml.Unmarshal(body, &cr)
if err != nil {
base.Error(err)
SessStore.DeleteAuthSession(sessionID)
w.WriteHeader(http.StatusBadRequest)
return
}
Expand All @@ -193,6 +196,7 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
// 动态码错误
if !dbdata.CheckOtp(username, otp, otpSecret) {
if sessionData.AddOtpErrCount(1) > maxOtpErrCount {
SessStore.DeleteAuthSession(sessionID)
http.Error(w, "TooManyError, please login again", http.StatusBadRequest)
return
}
Expand Down

0 comments on commit 96fd114

Please sign in to comment.