Skip to content

Commit

Permalink
Delete code after verification
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Nov 5, 2022
1 parent 9daa44f commit e4d4598
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func GetWeChatIDByCode(code string) string {
verificationMutex.Lock()
defer verificationMutex.Unlock()
value, okay := verificationMap[WeChatVerificationPurpose+code]
if okay {
delete(verificationMap, WeChatVerificationPurpose+code)
}
now := time.Now()
if !okay || int(now.Sub(value.time).Seconds()) >= VerificationValidMinutes*60 {
return ""
Expand All @@ -78,6 +81,9 @@ func VerifyCodeWithKey(key string, code string, purpose string) bool {
defer verificationMutex.Unlock()
value, okay := verificationMap[purpose+key]
now := time.Now()
if okay {
delete(verificationMap, purpose+key)
}
if !okay || int(now.Sub(value.time).Seconds()) >= VerificationValidMinutes*60 {
return false
}
Expand Down

0 comments on commit e4d4598

Please sign in to comment.