diff --git a/pkg/api/forget_passwords.go b/pkg/api/forget_passwords.go index 34afa5a1..f3899420 100644 --- a/pkg/api/forget_passwords.go +++ b/pkg/api/forget_passwords.go @@ -68,12 +68,13 @@ func (a *ForgetPasswordsApi) UserForgetPasswordRequestHandler(c *core.Context) ( return nil, errs.ErrTokenGenerating } - err = a.forgetPasswords.SendPasswordResetEmail(c, user, token, c.GetClientLocale()) + go func() { + err = a.forgetPasswords.SendPasswordResetEmail(c, user, token, c.GetClientLocale()) - if err != nil { - log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) - return nil, errs.Or(err, errs.ErrOperationFailed) - } + if err != nil { + log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) + } + }() return true, nil } diff --git a/pkg/api/users.go b/pkg/api/users.go index 9bdd1f38..eb441d5f 100644 --- a/pkg/api/users.go +++ b/pkg/api/users.go @@ -99,11 +99,13 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro if err != nil { log.ErrorfWithRequestId(c, "[users.UserRegisterHandler] failed to create email verify token for user \"uid:%d\", because %s", user.Uid, err.Error()) } else { - err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) + go func() { + err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) - if err != nil { - log.WarnfWithRequestId(c, "[users.UserRegisterHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error()) - } + if err != nil { + log.WarnfWithRequestId(c, "[users.UserRegisterHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error()) + } + }() } } @@ -362,11 +364,13 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs if err != nil { log.ErrorfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to create email verify token for user \"uid:%d\", because %s", user.Uid, err.Error()) } else { - err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) + go func() { + err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) - if err != nil { - log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error()) - } + if err != nil { + log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error()) + } + }() } } @@ -440,12 +444,13 @@ func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (int return nil, errs.ErrTokenGenerating } - err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) + go func() { + err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) - if err != nil { - log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) - return nil, errs.Or(err, errs.ErrOperationFailed) - } + if err != nil { + log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) + } + }() return true, nil } @@ -479,12 +484,13 @@ func (a *UsersApi) UserSendVerifyEmailByLoginedUserHandler(c *core.Context) (int return nil, errs.ErrTokenGenerating } - err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) + go func() { + err = a.users.SendVerifyEmail(user, token, c.GetClientLocale()) - if err != nil { - log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) - return nil, errs.Or(err, errs.ErrOperationFailed) - } + if err != nil { + log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error()) + } + }() return true, nil } diff --git a/src/consts/api.js b/src/consts/api.js index 6a3b0bbc..1c0a40a1 100644 --- a/src/consts/api.js +++ b/src/consts/api.js @@ -1,6 +1,4 @@ const defaultTimeout = 10000; // 10s -const requestVerifyEmailTimeout = 30000; // 30s -const requestForgetPasswordTimeout = 30000; // 30s const baseApiUrlPath = '/api'; const baseQrcodePath = '/qrcode'; const baseProxyUrlPath = '/proxy'; @@ -11,8 +9,6 @@ const amapJavascriptUrl = 'https://webapi.amap.com/maps?v=2.0'; export default { defaultTimeout: defaultTimeout, - requestVerifyEmailTimeout: requestVerifyEmailTimeout, - requestForgetPasswordTimeout: requestForgetPasswordTimeout, baseApiUrlPath: baseApiUrlPath, baseQrcodePath: baseQrcodePath, baseProxyUrlPath: baseProxyUrlPath, diff --git a/src/lib/services.js b/src/lib/services.js index 96c33ad7..bfd61fdf 100644 --- a/src/lib/services.js +++ b/src/lib/services.js @@ -101,8 +101,6 @@ export default { defaultCurrency, firstDayOfWeek, categories - }, { - timeout: api.requestVerifyEmailTimeout }); }, verifyEmail: ({ token, requestNewToken }) => { @@ -117,15 +115,11 @@ export default { return axios.post('verify_email/resend.json', { email, password - }, { - timeout: api.requestVerifyEmailTimeout }); }, requestResetPassword: ({ email }) => { return axios.post('forget_password/request.json', { email - }, { - timeout: api.requestForgetPasswordTimeout }); }, resetPassword: ({ email, token, password }) => { @@ -190,14 +184,10 @@ export default { shortDateFormat, longTimeFormat, shortTimeFormat - }, { - timeout: api.requestVerifyEmailTimeout }); }, resendVerifyEmailByLoginedUser: () => { - return axios.post('v1/users/verify_email/resend.json', {}, { - timeout: api.requestVerifyEmailTimeout - }); + return axios.post('v1/users/verify_email/resend.json'); }, get2FAStatus: () => { return axios.get('v1/users/2fa/status.json');