diff --git a/internalsdk/apimodels/api.go b/internalsdk/apimodels/api.go index bd708a5bb..66c25496e 100644 --- a/internalsdk/apimodels/api.go +++ b/internalsdk/apimodels/api.go @@ -170,7 +170,7 @@ func SignupEmailResendCode(signupEmailResendBody *protos.SignupEmailResendReques req, err := http.NewRequest("POST", signUpResendUrl, bytes.NewBuffer(requestBody)) if err != nil { - log.Errorf("Error creating signup request: %v", err) + log.Errorf("Error email resend request request: %v", err) return false, err } @@ -188,7 +188,7 @@ func SignupEmailResendCode(signupEmailResendBody *protos.SignupEmailResendReques } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return false, log.Errorf("error while sign up %v", err) + return false, log.Errorf("error while email resend %v", err) } return true, nil } @@ -226,8 +226,8 @@ func SignupEmailConfirmation(signupEmailResendBody *protos.ConfirmSignupRequest) return true, nil } -func GetSalt(userName string) (*protos.GetSaltResponse, error) { - fullUrl := saltUrl + "?username=" + userName +func GetSalt(email string) (*protos.GetSaltResponse, error) { + fullUrl := saltUrl + "?username=" + email // Marshal the map to JSON req, err := http.NewRequest("GET", fullUrl, nil) diff --git a/internalsdk/session_model.go b/internalsdk/session_model.go index 8eb2accf3..79c17def3 100644 --- a/internalsdk/session_model.go +++ b/internalsdk/session_model.go @@ -597,7 +597,7 @@ func setUserIdAndToken(m *baseModel, userId int, token string) error { }) } -func getUserSalt(m *baseModel, userName string) ([]byte, error) { +func getUserSalt(m *baseModel, email string) ([]byte, error) { userSalt, err := pathdb.Get[[]byte](m.db, pathUserSalt) if err != nil { return nil, err @@ -606,7 +606,7 @@ func getUserSalt(m *baseModel, userName string) ([]byte, error) { return userSalt, nil } - salt, err := apimodels.GetSalt(userName) + salt, err := apimodels.GetSalt(email) if err != nil { return nil, err } @@ -780,8 +780,14 @@ func signup(session *SessionModel, email string, password string, username strin } func signupEmailResend(session *SessionModel, email string) error { + salt, err := getUserSalt(session.baseModel, email) + if err != nil { + return err + } + signUpEmailResendRequestBody := &protos.SignupEmailResendRequest{ Email: email, + Salt: salt, } log.Debugf("Signup request body %v", signUpEmailResendRequestBody)