Skip to content

Commit

Permalink
Change Salt API to use email.
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Dec 11, 2023
1 parent 69f2267 commit 6b822f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions internalsdk/apimodels/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6b822f5

Please sign in to comment.