Module: Auth0::Api::V1::Users

Included in:
Auth0::Api::V1
Defined in:
lib/auth0/api/v1/users.rb

Overview

Instance Method Summary collapse

Instance Method Details

#change_password_ticket(user_id, new_password, result_url = nil) ⇒ Object



76
77
78
79
80
# File 'lib/auth0/api/v1/users.rb', line 76

def change_password_ticket(user_id, new_password, result_url = nil)
  request_params = { 'newPassword' => new_password, 'resultUrl' => result_url }
  path = "/api/users/#{user_id}/change_password_ticket"
  post(path, request_params)
end

#client_users(client_id = @client_id) ⇒ Object



56
57
58
59
# File 'lib/auth0/api/v1/users.rb', line 56

def client_users(client_id = @client_id)
  path = "/api/clients/#{client_id}/users"
  get(path)
end

#connection_users(connection_name, search = nil) ⇒ Object Also known as: search_connection_users



35
36
37
38
39
# File 'lib/auth0/api/v1/users.rb', line 35

def connection_users(connection_name, search = nil)
  path = "/api/connections/#{connection_name}/users"
  path += "?search=#{search}" unless search.to_s.empty?
  get(path)
end

#create_public_key(user_id, device, public_key) ⇒ Object



90
91
92
93
94
# File 'lib/auth0/api/v1/users.rb', line 90

def create_public_key(user_id, device, public_key)
  path = "/api/users/#{user_id}/public_key"
  request_params = { device: device, public_key: public_key }
  post(path, request_params)
end

#create_user(email, password, connection_name, request_params = {}) ⇒ Object



62
63
64
65
66
67
# File 'lib/auth0/api/v1/users.rb', line 62

def create_user(email, password, connection_name, request_params = {})
  options = { email: email, password: password, connection: connection_name }
  request_params.merge!(options)
  path = '/api/users'
  post(path, request_params)
end

#delete_user(user_id) ⇒ Object



144
145
146
147
148
# File 'lib/auth0/api/v1/users.rb', line 144

def delete_user(user_id)
  raise Auth0::MissingUserId, 'if you want to remove all users use delete_users method' if user_id.to_s.empty?
  path = "/api/users/#{user_id}"
  delete(path)
end

#delete_usersObject

https://auth0.com/docs/api#!#delete–api-users

This will remove all your users



138
139
140
141
# File 'lib/auth0/api/v1/users.rb', line 138

def delete_users
  path = '/api/users/'
  delete(path)
end

#enterpriseconnections_users(search_criteria = nil, per_page = 500) ⇒ Object



44
45
46
47
# File 'lib/auth0/api/v1/users.rb', line 44

def enterpriseconnections_users(search_criteria = nil, per_page = 500)
  path = "/api/enterpriseconnections/users?search=#{search_criteria}&per_page=#{per_page.to_i}"
  get(path)
end

#patch_user_metadata(user_id, metadata = {}) ⇒ Object



130
131
132
133
# File 'lib/auth0/api/v1/users.rb', line 130

def (user_id,  = {})
  path = "/api/users/#{user_id}/metadata"
  patch(path, )
end

#revoke_user_device_public_key(user_id, device) ⇒ Object



157
158
159
160
# File 'lib/auth0/api/v1/users.rb', line 157

def revoke_user_device_public_key(user_id, device)
  path = "/api/users/#{user_id}/publickey?device=#{device}"
  delete(path)
end

#revoke_user_refresh_token(user_id, refresh_token) ⇒ Object



151
152
153
154
# File 'lib/auth0/api/v1/users.rb', line 151

def revoke_user_refresh_token(user_id, refresh_token)
  path = "/api/users/#{user_id}/refresh_tokens/#{refresh_token}"
  delete(path)
end

#send_verification_email(user_id) ⇒ Object



70
71
72
73
# File 'lib/auth0/api/v1/users.rb', line 70

def send_verification_email(user_id)
  path = "/api/users/#{user_id}/send_verification_email"
  post(path)
end

#socialconnections_users(search_criteria = nil, per_page = 500) ⇒ Object



50
51
52
53
# File 'lib/auth0/api/v1/users.rb', line 50

def socialconnections_users(search_criteria = nil, per_page = 500)
  path = "/api/socialconnections/users?search=#{search_criteria}&per_page=#{per_page.to_i}"
  get(path)
end

#update_user_email(user_id, email, verify = true) ⇒ Object



97
98
99
100
101
# File 'lib/auth0/api/v1/users.rb', line 97

def update_user_email(user_id, email, verify = true)
  path = "/api/users/#{user_id}/email"
  request_params = { email: email, verify: verify }
  put(path, request_params)
end

#update_user_metadata(user_id, metadata = {}) ⇒ Object

https://auth0.com/docs/api#!#put–api-users–user_id–metadata This will overwrite user's metadata, be really carefull, preffer using patch instead



105
106
107
108
# File 'lib/auth0/api/v1/users.rb', line 105

def (user_id,  = {})
  path = "/api/users/#{user_id}/metadata"
  put(path, )
end

#update_user_password(user_id, password, verify = true) ⇒ Object



111
112
113
114
115
# File 'lib/auth0/api/v1/users.rb', line 111

def update_user_password(user_id, password, verify = true)
  path = "/api/users/#{user_id}/password"
  request_params = { password: password, verify: verify }
  put(path, request_params)
end

#update_user_password_using_email(email, password, connection_name, verify = true) ⇒ Object



118
119
120
121
122
123
124
125
126
127
# File 'lib/auth0/api/v1/users.rb', line 118

def update_user_password_using_email(email, password, connection_name, verify = true)
  request_params = {
    email:      email,
    password:   password,
    connection: connection_name,
    verify:     verify
  }
  path = "/api/users/#{email}/password"
  put(path, request_params)
end

#user(user_id) ⇒ Object Also known as: get_user



20
21
22
23
# File 'lib/auth0/api/v1/users.rb', line 20

def user(user_id)
  path = "/api/users/#{user_id}"
  get(path)
end

#user_devices(user_id) ⇒ Object



28
29
30
31
# File 'lib/auth0/api/v1/users.rb', line 28

def user_devices(user_id)
  path = "/api/users/#{user_id}/devices"
  get(path)
end

#users(search = nil) ⇒ Object Also known as: users_search, get_users



10
11
12
13
14
# File 'lib/auth0/api/v1/users.rb', line 10

def users(search = nil)
  path = '/api/users'
  path += "?search=#{search}" unless search.to_s.empty?
  get(path)
end

#verification_ticket(user_id, result_url = nil) ⇒ Object



83
84
85
86
87
# File 'lib/auth0/api/v1/users.rb', line 83

def verification_ticket(user_id, result_url = nil)
  request_params = { 'resultUrl' => result_url }
  path = "/api/users/#{user_id}/verification_ticket"
  post(path, request_params)
end