Skip to content

Commit

Permalink
feat: Add user lock, unlock & support user_lockout in instance restri…
Browse files Browse the repository at this point in the history
…ctions settings
  • Loading branch information
Mark Pitsilos committed Oct 6, 2023
1 parent 9fa920a commit bdfb193
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
24 changes: 15 additions & 9 deletions clerk/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,24 @@ func (s *InstanceService) Update(params UpdateInstanceParams) error {
}

type InstanceRestrictionsResponse struct {
Object string `json:"object"`
Allowlist bool `json:"allowlist"`
Blocklist bool `json:"blocklist"`
BlockEmailSubaddresses bool `json:"block_email_subaddresses"`
BlockDisposableEmailDomains bool `json:"block_disposable_email_domains"`
Object string `json:"object"`
Allowlist bool `json:"allowlist"`
Blocklist bool `json:"blocklist"`
BlockEmailSubaddresses bool `json:"block_email_subaddresses"`
BlockDisposableEmailDomains bool `json:"block_disposable_email_domains"`
UserLockout bool `json:"user_lockout"`
MaxFailedVerificationAttempts *int64 `json:"max_failed_verification_attempts"`
LockoutDurationMinutes *int64 `json:"lockout_duration_minutes"`
}

type UpdateRestrictionsParams struct {
Allowlist *bool `json:"allowlist,omitempty"`
Blocklist *bool `json:"blocklist,omitempty"`
BlockEmailSubaddresses *bool `json:"block_email_subaddresses,omitempty"`
BlockDisposableEmailDomains *bool `json:"block_disposable_email_domains,omitempty"`
Allowlist *bool `json:"allowlist,omitempty"`
Blocklist *bool `json:"blocklist,omitempty"`
BlockEmailSubaddresses *bool `json:"block_email_subaddresses,omitempty"`
BlockDisposableEmailDomains *bool `json:"block_disposable_email_domains,omitempty"`
UserLockout *bool `json:"user_lockout,omitempty"`
MaxFailedVerificationAttempts *int64 `json:"max_failed_verification_attempts,omitempty"`
LockoutDurationMinutes *int64 `json:"lockout_duration_minutes,omitempty"`
}

func (s *InstanceService) UpdateRestrictions(params UpdateRestrictionsParams) (*InstanceRestrictionsResponse, error) {
Expand Down
24 changes: 24 additions & 0 deletions clerk/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@ func (s *UsersService) Unban(userID string) (*User, error) {
return &response, nil
}

func (s *UsersService) Lock(userID string) (*User, error) {
url := fmt.Sprintf("%s/%s/lock", UsersUrl, userID)
req, _ := s.client.NewRequest(http.MethodPost, url)

var response User
if _, err := s.client.Do(req, &response); err != nil {
return nil, err
}

return &response, nil
}

func (s *UsersService) Unlock(userID string) (*User, error) {
url := fmt.Sprintf("%s/%s/unlock", UsersUrl, userID)
req, _ := s.client.NewRequest(http.MethodPost, url)

var response User
if _, err := s.client.Do(req, &response); err != nil {
return nil, err
}

return &response, nil
}

type ListMembershipsParams struct {
Limit *int
Offset *int
Expand Down

0 comments on commit bdfb193

Please sign in to comment.