Porównaj commity

...

2 Commity

Autor SHA1 Wiadomość Data
Xeronith cdf258e158 fix(api): 🩹 exclude tokens from response 2023-08-05 13:06:45 +03:30
Xeronith 9640fc47a5 fix(components): 🐛 resolve username and email case sensitiviy issue 2023-08-05 13:06:18 +03:30
4 zmienionych plików z 15 dodań i 14 usunięć

Wyświetl plik

@ -21,6 +21,6 @@ func LoginService(context IContext, input *LoginRequest) (result *LoginResult, e
result = context.ResultContainer().(*LoginResult)
result.Username = commandResult.Username()
result.Token = commandResult.Token()
result.Token = "Automatic"
return result, nil
}

Wyświetl plik

@ -20,7 +20,7 @@ func SignupService(context IContext, input *SignupRequest) (result *SignupResult
context.SetAuthCookie(commandResult.Token())
result = context.ResultContainer().(*SignupResult)
result.Token = commandResult.Token()
result.Token = "Automatic"
result.Code = commandResult.Code()
return result, nil
}

Wyświetl plik

@ -20,6 +20,6 @@ func VerifyService(context IContext, input *VerifyRequest) (result *VerifyResult
context.SetAuthCookie(commandResult.Token())
result = context.ResultContainer().(*VerifyResult)
result.Token = commandResult.Token()
result.Token = "Automatic"
return result, nil
}

Wyświetl plik

@ -344,6 +344,10 @@ func (result signupResult) Code() string {
//endregion
func (manager *spiManager) Signup(username string, email string, password string, editor Identity) (result ISignupResult, err error) {
username = strings.ToLower(username)
email = strings.ToLower(email)
if !validators.UsernameIsValid(username) {
return nil, ERROR_INVALID_USERNAME_FOR_SIGNUP
}
@ -362,9 +366,6 @@ func (manager *spiManager) Signup(username string, email string, password string
}
}()
username = strings.ToLower(username)
email = strings.ToLower(email)
editor.Lock(SIGNUP_REQUEST)
defer editor.Unlock(SIGNUP_REQUEST)
@ -395,6 +396,8 @@ func (result resendVerificationCodeResult) Code() string {
//endregion
func (manager *spiManager) ResendVerificationCode(email string, editor Identity) (result IResendVerificationCodeResult, err error) {
email = strings.ToLower(email)
if !validators.EmailIsValid(email) {
return nil, ERROR_INVALID_EMAIL_FOR_RESEND_VERIFICATION_CODE
}
@ -405,8 +408,6 @@ func (manager *spiManager) ResendVerificationCode(email string, editor Identity)
}
}()
email = strings.ToLower(email)
editor.Lock(RESEND_VERIFICATION_CODE_REQUEST)
defer editor.Unlock(RESEND_VERIFICATION_CODE_REQUEST)
@ -437,6 +438,8 @@ func (result verifyResult) Token() string {
//endregion
func (manager *spiManager) Verify(email string, token string, code string, editor Identity) (result IVerifyResult, err error) {
email = strings.ToLower(email)
if !validators.EmailIsValid(email) {
return nil, ERROR_INVALID_EMAIL_FOR_VERIFY
}
@ -447,8 +450,6 @@ func (manager *spiManager) Verify(email string, token string, code string, edito
}
}()
email = strings.ToLower(email)
editor.Lock(VERIFY_REQUEST)
defer editor.Unlock(VERIFY_REQUEST)
@ -485,6 +486,8 @@ func (result loginResult) Token() string {
//endregion
func (manager *spiManager) Login(email string, password string, editor Identity) (result ILoginResult, err error) {
email = strings.ToLower(email)
if !validators.EmailIsValid(email) {
return nil, ERROR_INVALID_EMAIL_FOR_LOGIN
}
@ -499,8 +502,6 @@ func (manager *spiManager) Login(email string, password string, editor Identity)
}
}()
email = strings.ToLower(email)
editor.Lock(LOGIN_REQUEST)
defer editor.Unlock(LOGIN_REQUEST)
@ -687,14 +688,14 @@ func NewResetPasswordResult(_ interface{}) IResetPasswordResult {
//endregion
func (manager *spiManager) ResetPassword(usernameOrEmail string, editor Identity) (result IResetPasswordResult, err error) {
usernameOrEmail = strings.ToLower(usernameOrEmail)
defer func() {
if reason := recover(); reason != nil {
err = manager.Error(reason)
}
}()
usernameOrEmail = strings.ToLower(usernameOrEmail)
editor.Lock(RESET_PASSWORD_REQUEST)
defer editor.Unlock(RESET_PASSWORD_REQUEST)