From 679084bc67cf4982935cc31490aa528c8355f7d4 Mon Sep 17 00:00:00 2001 From: Mark Pitsilos Date: Thu, 12 Oct 2023 02:43:33 +0300 Subject: [PATCH] feat: Add user lock & unlock operations --- clerk/users.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clerk/users.go b/clerk/users.go index ca18985b..12ddcf9d 100644 --- a/clerk/users.go +++ b/clerk/users.go @@ -35,6 +35,7 @@ type User struct { UnsafeMetadata interface{} `json:"unsafe_metadata"` LastSignInAt *int64 `json:"last_sign_in_at"` Banned bool `json:"banned"` + Locked bool `json:"locked"` ExternalID *string `json:"external_id"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` @@ -304,6 +305,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