Skip to content

Commit

Permalink
Added resend verification for email and phone
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jan 13, 2020
1 parent f26a564 commit 5173ab3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,31 @@ func (c *Client) ResetPassword(token, password, passwordConfirm string) (err err
return
}

// ResendEmailVerification will resend an email to the user
//
// For more information: https://docs.tonicpow.com/#a12a3eff-491b-4079-99f6-07497b9e4efe
func (c *Client) ResendEmailVerification(userID uint64) (err error) {

// Basic requirements
if userID == 0 {
err = fmt.Errorf("missing required attribute: %s", fieldID)
return
}

// Start the post data
data := map[string]string{fieldID: fmt.Sprintf("%d", userID)}

// Fire the request
var response string
if response, err = c.request(fmt.Sprintf("%s/verify/%s/send", modelUser, fieldEmail), http.MethodPost, data, ""); err != nil {
return
}

// Only a 200 is treated as a success
err = c.error(http.StatusOK, response)
return
}

// CompleteEmailVerification will complete an email verification with a given token
//
// For more information: https://docs.tonicpow.com/#f5081800-a224-4f36-8014-94981f0bd55d
Expand All @@ -290,6 +315,31 @@ func (c *Client) CompleteEmailVerification(token string) (err error) {
return
}

// ResendPhoneVerification will resend a phone verification code to the user
//
// For more information: https://docs.tonicpow.com/#fcc4fe4d-f298-45bd-b51e-a5c107834528
func (c *Client) ResendPhoneVerification(userID uint64) (err error) {

// Basic requirements
if userID == 0 {
err = fmt.Errorf("missing required attribute: %s", fieldID)
return
}

// Start the post data
data := map[string]string{fieldID: fmt.Sprintf("%d", userID)}

// Fire the request
var response string
if response, err = c.request(fmt.Sprintf("%s/verify/%s/send", modelUser, fieldPhone), http.MethodPost, data, ""); err != nil {
return
}

// Only a 200 is treated as a success
err = c.error(http.StatusOK, response)
return
}

// CompletePhoneVerification will complete a phone verification with a given code and number
//
// For more information: https://docs.tonicpow.com/#573403c4-b872-475d-ac04-de32a88ecd19
Expand Down

0 comments on commit 5173ab3

Please sign in to comment.