Skip to content

Commit

Permalink
[TIC-878] Resend email confirmation (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
itailevi98 authored Jun 10, 2024
1 parent e8dfcb5 commit 9663333
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
29 changes: 29 additions & 0 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ClientInterface interface {
DisableUserCanCreateOrgs(userID uuid.UUID) (bool, error)
ClearUserPassword(userID uuid.UUID) (bool, error)
DisableUser2fa(userID uuid.UUID) (bool, error)
ResendEmailConfirmation(userID uuid.UUID) (bool, error)

// org endpoints
AllowOrgToSetupSamlConnection(orgID uuid.UUID) (bool, error)
Expand Down Expand Up @@ -790,6 +791,34 @@ func (o *Client) InviteUserToOrg(params models.InviteUserToOrg) (bool, error) {
return true, nil
}

// ResendEmailConfirmation will resend the email confirmation email to a user.
func (o *Client) ResendEmailConfirmation(userID uuid.UUID) (bool, error) {
urlPostfix := "resend_email_confirmation"

type ResendEmailConfirmationParams struct {
UserID uuid.UUID `json:"user_id"`
}

bodyParams := ResendEmailConfirmationParams{
UserID: userID,
}
bodyJSON, err := json.Marshal(bodyParams)
if err != nil {
return false, fmt.Errorf("Error on marshalling body params: %w", err)
}

queryResponse, err := o.queryHelper.Post(o.integrationAPIKey, urlPostfix, nil, bodyJSON)
if err != nil {
return false, fmt.Errorf("Error on resending email confirmation to user: %w", err)
}

if err := o.returnErrorMessageIfNotOk(queryResponse); err != nil {
return false, fmt.Errorf("Error on resending email confirmation to user: %w", err)
}

return true, nil
}

// public methods for orgs

// FetchOrg will fetch an org's data.
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ func (o *OrgRoleStructure) UnmarshalJSON(data []byte) error {

*o = o.FromString(s)
return nil
}
}
8 changes: 4 additions & 4 deletions pkg/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type UserMetadata struct {

// OrgInfo is the information about an organization a user is in.
type OrgInfo struct {
OrgID uuid.UUID `json:"org_id"`
OrgName string `json:"org_name"`
OrgID uuid.UUID `json:"org_id"`
OrgName string `json:"org_name"`
OrgRoleStructure OrgRoleStructure `json:"org_role_structure"`
UserRole string `json:"user_role"`
AdditionalRoles []string `json:"additional_roles"`
UserRole string `json:"user_role"`
AdditionalRoles []string `json:"additional_roles"`
}

// UserList is a paged list of users. The actual fetched users are in the Users field, and the
Expand Down

0 comments on commit 9663333

Please sign in to comment.