@@ -5,15 +5,13 @@ import (
55 "time"
66
77 "github.com/answerdev/answer/internal/entity"
8- "github.com/davecgh/go-spew/spew"
98)
109
1110// ValidationStrategy
1211// true pass
1312// false need captcha
1413func (cs * CaptchaService ) ValidationStrategy (ctx context.Context , unit , actionType string ) bool {
1514 info , err := cs .captchaRepo .GetActionType (ctx , unit , actionType )
16- spew .Dump ("[ValidationStrategy=验证策略]" , unit , actionType , info , err )
1715 if err != nil {
1816 //No record, no processing
1917 //
@@ -51,12 +49,10 @@ func (cs *CaptchaService) ValidationStrategy(ctx context.Context, unit, actionTy
5149
5250func (cs * CaptchaService ) CaptchaActionEmail (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
5351 // You need a verification code every time
54- spew .Dump ("[CaptchaActionEmail]" , actioninfo )
5552 return false
5653}
5754
5855func (cs * CaptchaService ) CaptchaActionPassword (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
59- spew .Dump ("[CaptchaActionPassword]" , actioninfo )
6056 setNum := 3
6157 setTime := int64 (60 * 30 ) //seconds
6258 now := time .Now ().Unix ()
@@ -70,7 +66,6 @@ func (cs *CaptchaService) CaptchaActionPassword(ctx context.Context, unit string
7066}
7167
7268func (cs * CaptchaService ) CaptchaActionEditUserinfo (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
73- spew .Dump ("[CaptchaActionEditUserinfo]" , actioninfo )
7469 setNum := 3
7570 setTime := int64 (60 * 30 ) //seconds
7671 now := time .Now ().Unix ()
@@ -84,7 +79,6 @@ func (cs *CaptchaService) CaptchaActionEditUserinfo(ctx context.Context, unit st
8479}
8580
8681func (cs * CaptchaService ) CaptchaActionQuestion (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
87- spew .Dump ("[CaptchaActionQuestion]" , actioninfo )
8882 setNum := 10
8983 setTime := int64 (5 ) //seconds
9084 now := time .Now ().Unix ()
@@ -95,7 +89,6 @@ func (cs *CaptchaService) CaptchaActionQuestion(ctx context.Context, unit string
9589}
9690
9791func (cs * CaptchaService ) CaptchaActionAnswer (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
98- spew .Dump ("[CaptchaActionAnswer]" , actioninfo )
9992 setNum := 10
10093 setTime := int64 (5 ) //seconds
10194 now := time .Now ().Unix ()
@@ -106,7 +99,6 @@ func (cs *CaptchaService) CaptchaActionAnswer(ctx context.Context, unit string,
10699}
107100
108101func (cs * CaptchaService ) CaptchaActionComment (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
109- spew .Dump ("[CaptchaActionComment]" , actioninfo )
110102 setNum := 30
111103 setTime := int64 (1 ) //seconds
112104 now := time .Now ().Unix ()
@@ -117,7 +109,6 @@ func (cs *CaptchaService) CaptchaActionComment(ctx context.Context, unit string,
117109}
118110
119111func (cs * CaptchaService ) CaptchaActionEdit (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
120- spew .Dump ("[CaptchaActionEdit]" , actioninfo )
121112 setNum := 10
122113 if actioninfo .Num >= setNum {
123114 return false
@@ -126,7 +117,6 @@ func (cs *CaptchaService) CaptchaActionEdit(ctx context.Context, unit string, ac
126117}
127118
128119func (cs * CaptchaService ) CaptchaActionInvitationAnswer (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
129- spew .Dump ("[CaptchaActionInvitationAnswer]" , actioninfo )
130120 setNum := 30
131121 if actioninfo .Num >= setNum {
132122 return false
@@ -138,7 +128,6 @@ func (cs *CaptchaService) CaptchaActionSearch(ctx context.Context, unit string,
138128 now := time .Now ().Unix ()
139129 setNum := 20
140130 setTime := int64 (60 ) //seconds
141- spew .Dump ("[CaptchaActionSearch]" , unit , actioninfo , now - int64 (actioninfo .LastTime ))
142131 if now - int64 (actioninfo .LastTime ) <= setTime && actioninfo .Num >= setNum {
143132 return false
144133 }
@@ -152,15 +141,13 @@ func (cs *CaptchaService) CaptchaActionReport(ctx context.Context, unit string,
152141 setNum := 30
153142 setTime := int64 (1 ) //seconds
154143 now := time .Now ().Unix ()
155- spew .Dump ("[CaptchaActionReport]" , actioninfo , now - int64 (actioninfo .LastTime ))
156144 if now - actioninfo .LastTime <= setTime || actioninfo .Num >= setNum {
157145 return false
158146 }
159147 return true
160148}
161149
162150func (cs * CaptchaService ) CaptchaActionDelete (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
163- spew .Dump ("[CaptchaActionDelete]" , actioninfo )
164151 setNum := 5
165152 setTime := int64 (5 ) //seconds
166153 now := time .Now ().Unix ()
@@ -171,7 +158,6 @@ func (cs *CaptchaService) CaptchaActionDelete(ctx context.Context, unit string,
171158}
172159
173160func (cs * CaptchaService ) CaptchaActionVote (ctx context.Context , unit string , actioninfo * entity.ActionRecordInfo ) bool {
174- spew .Dump ("[CaptchaActionVote]" , actioninfo )
175161 setNum := 40
176162 if actioninfo .Num >= setNum {
177163 return false
0 commit comments