Skip to content

Commit 6cc4a2b

Browse files
committed
Merge branch 'release/1.1.1' into github-main
2 parents 4843a8d + 967c2df commit 6cc4a2b

File tree

7 files changed

+23
-16
lines changed

7 files changed

+23
-16
lines changed

internal/controller/user_controller.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {
121121

122122
resp, err := uc.userService.EmailLogin(ctx, req)
123123
if err != nil {
124-
_, _ = uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionEmail, ctx.ClientIP())
124+
_, _ = uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionPassword, ctx.ClientIP())
125125
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
126126
ErrorField: "e_mail",
127127
ErrorMsg: translator.Tr(handler.GetLang(ctx), reason.EmailOrPasswordWrong),
@@ -541,8 +541,10 @@ func (uc *UserController) UserChangeEmailSendCode(ctx *gin.Context) {
541541
return
542542
}
543543
isAdmin := middleware.GetUserIsAdminModerator(ctx)
544+
544545
if !isAdmin {
545-
captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionPassword, req.UserID, req.CaptchaID, req.CaptchaCode)
546+
captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionEditUserinfo, req.UserID, req.CaptchaID, req.CaptchaCode)
547+
uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionEditUserinfo, req.UserID)
546548
if !captchaPass {
547549
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
548550
ErrorField: "captcha_code",
@@ -552,14 +554,16 @@ func (uc *UserController) UserChangeEmailSendCode(ctx *gin.Context) {
552554
return
553555
}
554556
}
557+
555558
resp, err := uc.userService.UserChangeEmailSendCode(ctx, req)
556559
if err != nil {
557560
handler.HandleResponse(ctx, err, resp)
558561
return
559562
}
560563
if !isAdmin {
561-
uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionPassword, req.UserID)
564+
uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionEditUserinfo, ctx.ClientIP())
562565
}
566+
563567
handler.HandleResponse(ctx, err, nil)
564568
}
565569

internal/service/action/captcha_strategy.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func (cs *CaptchaService) CaptchaActionPassword(ctx context.Context, unit string
5656
setNum := 3
5757
setTime := int64(60 * 30) //seconds
5858
now := time.Now().Unix()
59-
if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {
59+
if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {
6060
return false
6161
}
62-
if now-actioninfo.LastTime > setTime {
62+
if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {
6363
cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionPassword, "", 0)
6464
}
6565
return true
@@ -69,10 +69,10 @@ func (cs *CaptchaService) CaptchaActionEditUserinfo(ctx context.Context, unit st
6969
setNum := 3
7070
setTime := int64(60 * 30) //seconds
7171
now := time.Now().Unix()
72-
if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {
72+
if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {
7373
return false
7474
}
75-
if now-actioninfo.LastTime > setTime {
75+
if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {
7676
cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionEditUserinfo, "", 0)
7777
}
7878
return true

internal/service/uploader/upload.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (us *uploaderService) AvatarThumbFile(ctx *gin.Context, fileName string, si
160160

161161
func (us *uploaderService) UploadPostFile(ctx *gin.Context) (
162162
url string, err error) {
163-
url, err = us.tryToUploadByPlugin(ctx, plugin.UserAvatar)
163+
url, err = us.tryToUploadByPlugin(ctx, plugin.UserPost)
164164
if err != nil {
165165
return "", err
166166
}
@@ -186,7 +186,7 @@ func (us *uploaderService) UploadPostFile(ctx *gin.Context) (
186186

187187
func (us *uploaderService) UploadBrandingFile(ctx *gin.Context) (
188188
url string, err error) {
189-
url, err = us.tryToUploadByPlugin(ctx, plugin.UserAvatar)
189+
url, err = us.tryToUploadByPlugin(ctx, plugin.AdminBranding)
190190
if err != nil {
191191
return "", err
192192
}

plugin/storage.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var (
2121
".png": true,
2222
},
2323
AdminBranding: {
24-
".ico": true,
24+
".jpg": true,
25+
".jpeg": true,
26+
".png": true,
27+
".ico": true,
2528
},
2629
}
2730
)

ui/src/components/Unactivate/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const Index: React.FC<IProps> = () => {
3737
};
3838
}
3939
resendEmail(req)
40-
.then(() => {
41-
emailCaptcha.close();
40+
.then(async () => {
41+
await emailCaptcha.close();
4242
setSuccess(true);
4343
})
4444
.catch((err) => {

ui/src/pages/Search/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const Index = () => {
4949
}
5050

5151
getSearchResult(params)
52-
.then((resp) => {
53-
searchCaptcha.close();
52+
.then(async (resp) => {
53+
await searchCaptcha.close();
5454
setData(resp);
5555
})
5656
.catch((err) => {

ui/src/pages/Users/Register/components/SignUpForm/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ const Index: React.FC<Props> = ({ callback }) => {
105105
}
106106

107107
register(reqParams)
108-
.then((res) => {
109-
emailCaptcha.close();
108+
.then(async (res) => {
109+
await emailCaptcha.close();
110110
updateUser(res);
111111
callback();
112112
})

0 commit comments

Comments
 (0)