Merge branch 'test' into release/1.1.1

This commit is contained in:
LinkinStars 2023-08-02 17:29:59 +08:00
commit 967c2df4a1
7 changed files with 23 additions and 16 deletions

View File

@ -121,7 +121,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {
resp, err := uc.userService.EmailLogin(ctx, req)
if err != nil {
_, _ = uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionEmail, ctx.ClientIP())
_, _ = uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionPassword, ctx.ClientIP())
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
ErrorField: "e_mail",
ErrorMsg: translator.Tr(handler.GetLang(ctx), reason.EmailOrPasswordWrong),
@ -541,8 +541,10 @@ func (uc *UserController) UserChangeEmailSendCode(ctx *gin.Context) {
return
}
isAdmin := middleware.GetUserIsAdminModerator(ctx)
if !isAdmin {
captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionPassword, req.UserID, req.CaptchaID, req.CaptchaCode)
captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionEditUserinfo, req.UserID, req.CaptchaID, req.CaptchaCode)
uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionEditUserinfo, req.UserID)
if !captchaPass {
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
ErrorField: "captcha_code",
@ -552,14 +554,16 @@ func (uc *UserController) UserChangeEmailSendCode(ctx *gin.Context) {
return
}
}
resp, err := uc.userService.UserChangeEmailSendCode(ctx, req)
if err != nil {
handler.HandleResponse(ctx, err, resp)
return
}
if !isAdmin {
uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionPassword, req.UserID)
uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionEditUserinfo, ctx.ClientIP())
}
handler.HandleResponse(ctx, err, nil)
}

View File

@ -56,10 +56,10 @@ func (cs *CaptchaService) CaptchaActionPassword(ctx context.Context, unit string
setNum := 3
setTime := int64(60 * 30) //seconds
now := time.Now().Unix()
if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {
if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {
return false
}
if now-actioninfo.LastTime > setTime {
if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {
cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionPassword, "", 0)
}
return true
@ -69,10 +69,10 @@ func (cs *CaptchaService) CaptchaActionEditUserinfo(ctx context.Context, unit st
setNum := 3
setTime := int64(60 * 30) //seconds
now := time.Now().Unix()
if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {
if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {
return false
}
if now-actioninfo.LastTime > setTime {
if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {
cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionEditUserinfo, "", 0)
}
return true

View File

@ -160,7 +160,7 @@ func (us *uploaderService) AvatarThumbFile(ctx *gin.Context, fileName string, si
func (us *uploaderService) UploadPostFile(ctx *gin.Context) (
url string, err error) {
url, err = us.tryToUploadByPlugin(ctx, plugin.UserAvatar)
url, err = us.tryToUploadByPlugin(ctx, plugin.UserPost)
if err != nil {
return "", err
}
@ -186,7 +186,7 @@ func (us *uploaderService) UploadPostFile(ctx *gin.Context) (
func (us *uploaderService) UploadBrandingFile(ctx *gin.Context) (
url string, err error) {
url, err = us.tryToUploadByPlugin(ctx, plugin.UserAvatar)
url, err = us.tryToUploadByPlugin(ctx, plugin.AdminBranding)
if err != nil {
return "", err
}

View File

@ -21,7 +21,10 @@ var (
".png": true,
},
AdminBranding: {
".ico": true,
".jpg": true,
".jpeg": true,
".png": true,
".ico": true,
},
}
)

View File

@ -37,8 +37,8 @@ const Index: React.FC<IProps> = () => {
};
}
resendEmail(req)
.then(() => {
emailCaptcha.close();
.then(async () => {
await emailCaptcha.close();
setSuccess(true);
})
.catch((err) => {

View File

@ -49,8 +49,8 @@ const Index = () => {
}
getSearchResult(params)
.then((resp) => {
searchCaptcha.close();
.then(async (resp) => {
await searchCaptcha.close();
setData(resp);
})
.catch((err) => {

View File

@ -105,8 +105,8 @@ const Index: React.FC<Props> = ({ callback }) => {
}
register(reqParams)
.then((res) => {
emailCaptcha.close();
.then(async (res) => {
await emailCaptcha.close();
updateUser(res);
callback();
})