appwrite 10.1.2 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +36 -7
- data/lib/appwrite/enums/authentication_factor.rb +10 -0
- data/lib/appwrite/enums/authenticator_type.rb +7 -0
- data/lib/appwrite/enums/browser.rb +20 -0
- data/lib/appwrite/enums/compression.rb +9 -0
- data/lib/appwrite/enums/credit_card.rb +22 -0
- data/lib/appwrite/enums/execution_method.rb +12 -0
- data/lib/appwrite/enums/flag.rb +200 -0
- data/lib/appwrite/enums/image_format.rb +11 -0
- data/lib/appwrite/enums/image_gravity.rb +15 -0
- data/lib/appwrite/enums/index_type.rb +9 -0
- data/lib/appwrite/enums/messaging_provider_type.rb +9 -0
- data/lib/appwrite/enums/name.rb +19 -0
- data/lib/appwrite/enums/o_auth_provider.rb +45 -0
- data/lib/appwrite/enums/password_hash.rb +17 -0
- data/lib/appwrite/enums/relation_mutate.rb +9 -0
- data/lib/appwrite/enums/relationship_type.rb +10 -0
- data/lib/appwrite/enums/runtime.rb +50 -0
- data/lib/appwrite/enums/smtp_encryption.rb +9 -0
- data/lib/appwrite/models/health_certificate.rb +52 -0
- data/lib/appwrite/models/jwt.rb +27 -0
- data/lib/appwrite/models/membership.rb +5 -0
- data/lib/appwrite/models/message.rb +87 -0
- data/lib/appwrite/models/message_list.rb +32 -0
- data/lib/appwrite/models/mfa_challenge.rb +42 -0
- data/lib/appwrite/models/mfa_factors.rb +37 -0
- data/lib/appwrite/models/mfa_recovery_codes.rb +27 -0
- data/lib/appwrite/models/mfa_type.rb +32 -0
- data/lib/appwrite/models/provider.rb +67 -0
- data/lib/appwrite/models/provider_list.rb +32 -0
- data/lib/appwrite/models/session.rb +18 -3
- data/lib/appwrite/models/subscriber.rb +67 -0
- data/lib/appwrite/models/subscriber_list.rb +32 -0
- data/lib/appwrite/models/target.rb +62 -0
- data/lib/appwrite/models/target_list.rb +32 -0
- data/lib/appwrite/models/token.rb +8 -3
- data/lib/appwrite/models/topic.rb +62 -0
- data/lib/appwrite/models/topic_list.rb +32 -0
- data/lib/appwrite/models/user.rb +10 -0
- data/lib/appwrite/query.rb +53 -28
- data/lib/appwrite/services/account.rb +935 -168
- data/lib/appwrite/services/avatars.rb +3 -3
- data/lib/appwrite/services/databases.rb +22 -16
- data/lib/appwrite/services/functions.rb +3 -3
- data/lib/appwrite/services/health.rb +138 -0
- data/lib/appwrite/services/messaging.rb +1886 -0
- data/lib/appwrite/services/storage.rb +4 -4
- data/lib/appwrite/services/teams.rb +1 -1
- data/lib/appwrite/services/users.rb +475 -4
- data/lib/appwrite.rb +36 -0
- metadata +37 -2
@@ -31,6 +31,56 @@ module Appwrite
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
+
# Use this endpoint to allow a new user to register a new account in your
|
35
|
+
# project. After the user registration completes successfully, you can use
|
36
|
+
# the
|
37
|
+
# [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
|
38
|
+
# route to start verifying the user email address. To allow the new user to
|
39
|
+
# login to their new account, you need to create a new [account
|
40
|
+
# session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
|
41
|
+
#
|
42
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
43
|
+
# @param [String] email User email.
|
44
|
+
# @param [String] password New user password. Must be between 8 and 256 chars.
|
45
|
+
# @param [String] name User name. Max length: 128 chars.
|
46
|
+
#
|
47
|
+
# @return [User]
|
48
|
+
def create(user_id:, email:, password:, name: nil)
|
49
|
+
api_path = '/account'
|
50
|
+
|
51
|
+
if user_id.nil?
|
52
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
53
|
+
end
|
54
|
+
|
55
|
+
if email.nil?
|
56
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
57
|
+
end
|
58
|
+
|
59
|
+
if password.nil?
|
60
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
61
|
+
end
|
62
|
+
|
63
|
+
api_params = {
|
64
|
+
userId: user_id,
|
65
|
+
email: email,
|
66
|
+
password: password,
|
67
|
+
name: name,
|
68
|
+
}
|
69
|
+
|
70
|
+
api_headers = {
|
71
|
+
"content-type": 'application/json',
|
72
|
+
}
|
73
|
+
|
74
|
+
@client.call(
|
75
|
+
method: 'POST',
|
76
|
+
path: api_path,
|
77
|
+
headers: api_headers,
|
78
|
+
params: api_params,
|
79
|
+
response_type: Models::User
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
34
84
|
# Update currently logged in user account email address. After changing user
|
35
85
|
# address, the user confirmation status will get reset. A new confirmation
|
36
86
|
# email is not sent automatically however you can use the send confirmation
|
@@ -76,7 +126,7 @@ module Appwrite
|
|
76
126
|
|
77
127
|
# Get the list of identities for the currently logged in user.
|
78
128
|
#
|
79
|
-
# @param [
|
129
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
|
80
130
|
#
|
81
131
|
# @return [IdentityList]
|
82
132
|
def list_identities(queries: nil)
|
@@ -129,6 +179,34 @@ module Appwrite
|
|
129
179
|
end
|
130
180
|
|
131
181
|
|
182
|
+
# Use this endpoint to create a JSON Web Token. You can use the resulting JWT
|
183
|
+
# to authenticate on behalf of the current user when working with the
|
184
|
+
# Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
|
185
|
+
# from its creation and will be invalid if the user will logout in that time
|
186
|
+
# frame.
|
187
|
+
#
|
188
|
+
#
|
189
|
+
# @return [Jwt]
|
190
|
+
def create_jwt()
|
191
|
+
api_path = '/account/jwt'
|
192
|
+
|
193
|
+
api_params = {
|
194
|
+
}
|
195
|
+
|
196
|
+
api_headers = {
|
197
|
+
"content-type": 'application/json',
|
198
|
+
}
|
199
|
+
|
200
|
+
@client.call(
|
201
|
+
method: 'POST',
|
202
|
+
path: api_path,
|
203
|
+
headers: api_headers,
|
204
|
+
params: api_params,
|
205
|
+
response_type: Models::Jwt
|
206
|
+
)
|
207
|
+
end
|
208
|
+
|
209
|
+
|
132
210
|
# Get the list of latest security activity logs for the currently logged in
|
133
211
|
# user. Each log returns user IP address, location and date and time of log.
|
134
212
|
#
|
@@ -156,20 +234,20 @@ module Appwrite
|
|
156
234
|
end
|
157
235
|
|
158
236
|
|
159
|
-
#
|
237
|
+
# Enable or disable MFA on an account.
|
160
238
|
#
|
161
|
-
# @param [
|
239
|
+
# @param [] mfa Enable or disable MFA.
|
162
240
|
#
|
163
241
|
# @return [User]
|
164
|
-
def
|
165
|
-
api_path = '/account/
|
242
|
+
def update_mfa(mfa:)
|
243
|
+
api_path = '/account/mfa'
|
166
244
|
|
167
|
-
if
|
168
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
245
|
+
if mfa.nil?
|
246
|
+
raise Appwrite::Exception.new('Missing required parameter: "mfa"')
|
169
247
|
end
|
170
248
|
|
171
249
|
api_params = {
|
172
|
-
|
250
|
+
mfa: mfa,
|
173
251
|
}
|
174
252
|
|
175
253
|
api_headers = {
|
@@ -186,24 +264,23 @@ module Appwrite
|
|
186
264
|
end
|
187
265
|
|
188
266
|
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
267
|
+
# Add an authenticator app to be used as an MFA factor. Verify the
|
268
|
+
# authenticator using the [verify
|
269
|
+
# authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
|
270
|
+
# method.
|
192
271
|
#
|
193
|
-
# @param [
|
194
|
-
# @param [String] old_password Current user password. Must be at least 8 chars.
|
272
|
+
# @param [AuthenticatorType] type Type of authenticator. Must be `totp`
|
195
273
|
#
|
196
|
-
# @return [
|
197
|
-
def
|
198
|
-
api_path = '/account/
|
274
|
+
# @return [MfaType]
|
275
|
+
def create_mfa_authenticator(type:)
|
276
|
+
api_path = '/account/mfa/authenticators/{type}'
|
277
|
+
.gsub('{type}', type)
|
199
278
|
|
200
|
-
if
|
201
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
279
|
+
if type.nil?
|
280
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
202
281
|
end
|
203
282
|
|
204
283
|
api_params = {
|
205
|
-
password: password,
|
206
|
-
oldPassword: old_password,
|
207
284
|
}
|
208
285
|
|
209
286
|
api_headers = {
|
@@ -211,39 +288,37 @@ module Appwrite
|
|
211
288
|
}
|
212
289
|
|
213
290
|
@client.call(
|
214
|
-
method: '
|
291
|
+
method: 'POST',
|
215
292
|
path: api_path,
|
216
293
|
headers: api_headers,
|
217
294
|
params: api_params,
|
218
|
-
response_type: Models::
|
295
|
+
response_type: Models::MfaType
|
219
296
|
)
|
220
297
|
end
|
221
298
|
|
222
299
|
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
# /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
|
227
|
-
# endpoint to send a confirmation SMS.
|
300
|
+
# Verify an authenticator app after adding it using the [add
|
301
|
+
# authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
|
302
|
+
# method.
|
228
303
|
#
|
229
|
-
# @param [
|
230
|
-
# @param [String]
|
304
|
+
# @param [AuthenticatorType] type Type of authenticator.
|
305
|
+
# @param [String] otp Valid verification token.
|
231
306
|
#
|
232
307
|
# @return [User]
|
233
|
-
def
|
234
|
-
api_path = '/account/
|
308
|
+
def update_mfa_authenticator(type:, otp:)
|
309
|
+
api_path = '/account/mfa/authenticators/{type}'
|
310
|
+
.gsub('{type}', type)
|
235
311
|
|
236
|
-
if
|
237
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
312
|
+
if type.nil?
|
313
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
238
314
|
end
|
239
315
|
|
240
|
-
if
|
241
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
316
|
+
if otp.nil?
|
317
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
242
318
|
end
|
243
319
|
|
244
320
|
api_params = {
|
245
|
-
|
246
|
-
password: password,
|
321
|
+
otp: otp,
|
247
322
|
}
|
248
323
|
|
249
324
|
api_headers = {
|
@@ -251,7 +326,7 @@ module Appwrite
|
|
251
326
|
}
|
252
327
|
|
253
328
|
@client.call(
|
254
|
-
method: '
|
329
|
+
method: 'PUT',
|
255
330
|
path: api_path,
|
256
331
|
headers: api_headers,
|
257
332
|
params: api_params,
|
@@ -260,14 +335,26 @@ module Appwrite
|
|
260
335
|
end
|
261
336
|
|
262
337
|
|
263
|
-
#
|
338
|
+
# Delete an authenticator for a user by ID.
|
264
339
|
#
|
340
|
+
# @param [AuthenticatorType] type Type of authenticator.
|
341
|
+
# @param [String] otp Valid verification token.
|
265
342
|
#
|
266
|
-
# @return [
|
267
|
-
def
|
268
|
-
api_path = '/account/
|
343
|
+
# @return [User]
|
344
|
+
def delete_mfa_authenticator(type:, otp:)
|
345
|
+
api_path = '/account/mfa/authenticators/{type}'
|
346
|
+
.gsub('{type}', type)
|
347
|
+
|
348
|
+
if type.nil?
|
349
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
350
|
+
end
|
351
|
+
|
352
|
+
if otp.nil?
|
353
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
354
|
+
end
|
269
355
|
|
270
356
|
api_params = {
|
357
|
+
otp: otp,
|
271
358
|
}
|
272
359
|
|
273
360
|
api_headers = {
|
@@ -275,31 +362,31 @@ module Appwrite
|
|
275
362
|
}
|
276
363
|
|
277
364
|
@client.call(
|
278
|
-
method: '
|
365
|
+
method: 'DELETE',
|
279
366
|
path: api_path,
|
280
367
|
headers: api_headers,
|
281
368
|
params: api_params,
|
282
|
-
response_type: Models::
|
369
|
+
response_type: Models::User
|
283
370
|
)
|
284
371
|
end
|
285
372
|
|
286
373
|
|
287
|
-
#
|
288
|
-
#
|
289
|
-
#
|
374
|
+
# Begin the process of MFA verification after sign-in. Finish the flow with
|
375
|
+
# [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
|
376
|
+
# method.
|
290
377
|
#
|
291
|
-
# @param [
|
378
|
+
# @param [AuthenticationFactor] factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`.
|
292
379
|
#
|
293
|
-
# @return [
|
294
|
-
def
|
295
|
-
api_path = '/account/
|
380
|
+
# @return [MfaChallenge]
|
381
|
+
def create_mfa_challenge(factor:)
|
382
|
+
api_path = '/account/mfa/challenge'
|
296
383
|
|
297
|
-
if
|
298
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
384
|
+
if factor.nil?
|
385
|
+
raise Appwrite::Exception.new('Missing required parameter: "factor"')
|
299
386
|
end
|
300
387
|
|
301
388
|
api_params = {
|
302
|
-
|
389
|
+
factor: factor,
|
303
390
|
}
|
304
391
|
|
305
392
|
api_headers = {
|
@@ -307,42 +394,39 @@ module Appwrite
|
|
307
394
|
}
|
308
395
|
|
309
396
|
@client.call(
|
310
|
-
method: '
|
397
|
+
method: 'POST',
|
311
398
|
path: api_path,
|
312
399
|
headers: api_headers,
|
313
400
|
params: api_params,
|
314
|
-
response_type: Models::
|
401
|
+
response_type: Models::MfaChallenge
|
315
402
|
)
|
316
403
|
end
|
317
404
|
|
318
405
|
|
319
|
-
#
|
320
|
-
#
|
321
|
-
#
|
322
|
-
#
|
323
|
-
#
|
324
|
-
# /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
|
325
|
-
# endpoint to complete the process. The verification link sent to the user's
|
326
|
-
# email address is valid for 1 hour.
|
406
|
+
# Complete the MFA challenge by providing the one-time password. Finish the
|
407
|
+
# process of MFA verification by providing the one-time password. To begin
|
408
|
+
# the flow, use
|
409
|
+
# [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
|
410
|
+
# method.
|
327
411
|
#
|
328
|
-
# @param [String]
|
329
|
-
# @param [String]
|
412
|
+
# @param [String] challenge_id ID of the challenge.
|
413
|
+
# @param [String] otp Valid verification token.
|
330
414
|
#
|
331
|
-
# @return [
|
332
|
-
def
|
333
|
-
api_path = '/account/
|
415
|
+
# @return []
|
416
|
+
def update_mfa_challenge(challenge_id:, otp:)
|
417
|
+
api_path = '/account/mfa/challenge'
|
334
418
|
|
335
|
-
if
|
336
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
419
|
+
if challenge_id.nil?
|
420
|
+
raise Appwrite::Exception.new('Missing required parameter: "challengeId"')
|
337
421
|
end
|
338
422
|
|
339
|
-
if
|
340
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
423
|
+
if otp.nil?
|
424
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
341
425
|
end
|
342
426
|
|
343
427
|
api_params = {
|
344
|
-
|
345
|
-
|
428
|
+
challengeId: challenge_id,
|
429
|
+
otp: otp,
|
346
430
|
}
|
347
431
|
|
348
432
|
api_headers = {
|
@@ -350,56 +434,22 @@ module Appwrite
|
|
350
434
|
}
|
351
435
|
|
352
436
|
@client.call(
|
353
|
-
method: '
|
437
|
+
method: 'PUT',
|
354
438
|
path: api_path,
|
355
439
|
headers: api_headers,
|
356
440
|
params: api_params,
|
357
|
-
response_type: Models::Token
|
358
441
|
)
|
359
442
|
end
|
360
443
|
|
361
444
|
|
362
|
-
#
|
363
|
-
# **userId** and **secret** arguments will be passed as query parameters to
|
364
|
-
# the redirect URL you have provided when sending your request to the [POST
|
365
|
-
# /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
|
366
|
-
# endpoint.
|
367
|
-
#
|
368
|
-
# Please note that in order to avoid a [Redirect
|
369
|
-
# Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
370
|
-
# the only valid redirect URLs are the ones from domains you have set when
|
371
|
-
# adding your platforms in the console interface.
|
445
|
+
# List the factors available on the account to be used as a MFA challange.
|
372
446
|
#
|
373
|
-
# @param [String] user_id User ID.
|
374
|
-
# @param [String] secret Valid reset token.
|
375
|
-
# @param [String] password New user password. Must be at least 8 chars.
|
376
|
-
# @param [String] password_again Repeat new user password. Must be at least 8 chars.
|
377
447
|
#
|
378
|
-
# @return [
|
379
|
-
def
|
380
|
-
api_path = '/account/
|
381
|
-
|
382
|
-
if user_id.nil?
|
383
|
-
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
384
|
-
end
|
385
|
-
|
386
|
-
if secret.nil?
|
387
|
-
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
388
|
-
end
|
389
|
-
|
390
|
-
if password.nil?
|
391
|
-
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
392
|
-
end
|
393
|
-
|
394
|
-
if password_again.nil?
|
395
|
-
raise Appwrite::Exception.new('Missing required parameter: "passwordAgain"')
|
396
|
-
end
|
448
|
+
# @return [MfaFactors]
|
449
|
+
def list_mfa_factors()
|
450
|
+
api_path = '/account/mfa/factors'
|
397
451
|
|
398
452
|
api_params = {
|
399
|
-
userId: user_id,
|
400
|
-
secret: secret,
|
401
|
-
password: password,
|
402
|
-
passwordAgain: password_again,
|
403
453
|
}
|
404
454
|
|
405
455
|
api_headers = {
|
@@ -407,22 +457,24 @@ module Appwrite
|
|
407
457
|
}
|
408
458
|
|
409
459
|
@client.call(
|
410
|
-
method: '
|
460
|
+
method: 'GET',
|
411
461
|
path: api_path,
|
412
462
|
headers: api_headers,
|
413
463
|
params: api_params,
|
414
|
-
response_type: Models::
|
464
|
+
response_type: Models::MfaFactors
|
415
465
|
)
|
416
466
|
end
|
417
467
|
|
418
468
|
|
419
|
-
# Get
|
420
|
-
#
|
469
|
+
# Get recovery codes that can be used as backup for MFA flow. Before getting
|
470
|
+
# codes, they must be generated using
|
471
|
+
# [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
472
|
+
# method. An OTP challenge is required to read recovery codes.
|
421
473
|
#
|
422
474
|
#
|
423
|
-
# @return [
|
424
|
-
def
|
425
|
-
api_path = '/account/
|
475
|
+
# @return [MfaRecoveryCodes]
|
476
|
+
def get_mfa_recovery_codes()
|
477
|
+
api_path = '/account/mfa/recovery-codes'
|
426
478
|
|
427
479
|
api_params = {
|
428
480
|
}
|
@@ -436,18 +488,21 @@ module Appwrite
|
|
436
488
|
path: api_path,
|
437
489
|
headers: api_headers,
|
438
490
|
params: api_params,
|
439
|
-
response_type: Models::
|
491
|
+
response_type: Models::MfaRecoveryCodes
|
440
492
|
)
|
441
493
|
end
|
442
494
|
|
443
495
|
|
444
|
-
#
|
445
|
-
#
|
496
|
+
# Generate recovery codes as backup for MFA flow. It's recommended to
|
497
|
+
# generate and show then immediately after user successfully adds their
|
498
|
+
# authehticator. Recovery codes can be used as a MFA verification type in
|
499
|
+
# [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
|
500
|
+
# method.
|
446
501
|
#
|
447
502
|
#
|
448
|
-
# @return []
|
449
|
-
def
|
450
|
-
api_path = '/account/
|
503
|
+
# @return [MfaRecoveryCodes]
|
504
|
+
def create_mfa_recovery_codes()
|
505
|
+
api_path = '/account/mfa/recovery-codes'
|
451
506
|
|
452
507
|
api_params = {
|
453
508
|
}
|
@@ -457,27 +512,24 @@ module Appwrite
|
|
457
512
|
}
|
458
513
|
|
459
514
|
@client.call(
|
460
|
-
method: '
|
515
|
+
method: 'POST',
|
461
516
|
path: api_path,
|
462
517
|
headers: api_headers,
|
463
518
|
params: api_params,
|
519
|
+
response_type: Models::MfaRecoveryCodes
|
464
520
|
)
|
465
521
|
end
|
466
522
|
|
467
523
|
|
468
|
-
#
|
469
|
-
#
|
524
|
+
# Regenerate recovery codes that can be used as backup for MFA flow. Before
|
525
|
+
# regenerating codes, they must be first generated using
|
526
|
+
# [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
527
|
+
# method. An OTP challenge is required to regenreate recovery codes.
|
470
528
|
#
|
471
|
-
# @param [String] session_id Session ID. Use the string 'current' to get the current device session.
|
472
529
|
#
|
473
|
-
# @return [
|
474
|
-
def
|
475
|
-
api_path = '/account/
|
476
|
-
.gsub('{sessionId}', session_id)
|
477
|
-
|
478
|
-
if session_id.nil?
|
479
|
-
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
480
|
-
end
|
530
|
+
# @return [MfaRecoveryCodes]
|
531
|
+
def update_mfa_recovery_codes()
|
532
|
+
api_path = '/account/mfa/recovery-codes'
|
481
533
|
|
482
534
|
api_params = {
|
483
535
|
}
|
@@ -487,31 +539,29 @@ module Appwrite
|
|
487
539
|
}
|
488
540
|
|
489
541
|
@client.call(
|
490
|
-
method: '
|
542
|
+
method: 'PATCH',
|
491
543
|
path: api_path,
|
492
544
|
headers: api_headers,
|
493
545
|
params: api_params,
|
494
|
-
response_type: Models::
|
546
|
+
response_type: Models::MfaRecoveryCodes
|
495
547
|
)
|
496
548
|
end
|
497
549
|
|
498
550
|
|
499
|
-
#
|
500
|
-
# If session was created using an OAuth provider, this route can be used to
|
501
|
-
# "refresh" the access token.
|
551
|
+
# Update currently logged in user account name.
|
502
552
|
#
|
503
|
-
# @param [String]
|
553
|
+
# @param [String] name User name. Max length: 128 chars.
|
504
554
|
#
|
505
|
-
# @return [
|
506
|
-
def
|
507
|
-
api_path = '/account/
|
508
|
-
.gsub('{sessionId}', session_id)
|
555
|
+
# @return [User]
|
556
|
+
def update_name(name:)
|
557
|
+
api_path = '/account/name'
|
509
558
|
|
510
|
-
if
|
511
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
559
|
+
if name.nil?
|
560
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
512
561
|
end
|
513
562
|
|
514
563
|
api_params = {
|
564
|
+
name: name,
|
515
565
|
}
|
516
566
|
|
517
567
|
api_headers = {
|
@@ -523,29 +573,29 @@ module Appwrite
|
|
523
573
|
path: api_path,
|
524
574
|
headers: api_headers,
|
525
575
|
params: api_params,
|
526
|
-
response_type: Models::
|
576
|
+
response_type: Models::User
|
527
577
|
)
|
528
578
|
end
|
529
579
|
|
530
580
|
|
531
|
-
#
|
532
|
-
#
|
533
|
-
#
|
534
|
-
# Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
|
535
|
-
# instead.
|
581
|
+
# Update currently logged in user password. For validation, user is required
|
582
|
+
# to pass in the new password, and the old password. For users created with
|
583
|
+
# OAuth, Team Invites and Magic URL, oldPassword is optional.
|
536
584
|
#
|
537
|
-
# @param [String]
|
585
|
+
# @param [String] password New user password. Must be at least 8 chars.
|
586
|
+
# @param [String] old_password Current user password. Must be at least 8 chars.
|
538
587
|
#
|
539
|
-
# @return []
|
540
|
-
def
|
541
|
-
api_path = '/account/
|
542
|
-
.gsub('{sessionId}', session_id)
|
588
|
+
# @return [User]
|
589
|
+
def update_password(password:, old_password: nil)
|
590
|
+
api_path = '/account/password'
|
543
591
|
|
544
|
-
if
|
545
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
592
|
+
if password.nil?
|
593
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
546
594
|
end
|
547
595
|
|
548
596
|
api_params = {
|
597
|
+
password: password,
|
598
|
+
oldPassword: old_password,
|
549
599
|
}
|
550
600
|
|
551
601
|
api_headers = {
|
@@ -553,17 +603,538 @@ module Appwrite
|
|
553
603
|
}
|
554
604
|
|
555
605
|
@client.call(
|
556
|
-
method: '
|
606
|
+
method: 'PATCH',
|
557
607
|
path: api_path,
|
558
608
|
headers: api_headers,
|
559
609
|
params: api_params,
|
610
|
+
response_type: Models::User
|
560
611
|
)
|
561
612
|
end
|
562
613
|
|
563
614
|
|
564
|
-
#
|
565
|
-
#
|
566
|
-
#
|
615
|
+
# Update the currently logged in user's phone number. After updating the
|
616
|
+
# phone number, the phone verification status will be reset. A confirmation
|
617
|
+
# SMS is not sent automatically, however you can use the [POST
|
618
|
+
# /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
|
619
|
+
# endpoint to send a confirmation SMS.
|
620
|
+
#
|
621
|
+
# @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
|
622
|
+
# @param [String] password User password. Must be at least 8 chars.
|
623
|
+
#
|
624
|
+
# @return [User]
|
625
|
+
def update_phone(phone:, password:)
|
626
|
+
api_path = '/account/phone'
|
627
|
+
|
628
|
+
if phone.nil?
|
629
|
+
raise Appwrite::Exception.new('Missing required parameter: "phone"')
|
630
|
+
end
|
631
|
+
|
632
|
+
if password.nil?
|
633
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
634
|
+
end
|
635
|
+
|
636
|
+
api_params = {
|
637
|
+
phone: phone,
|
638
|
+
password: password,
|
639
|
+
}
|
640
|
+
|
641
|
+
api_headers = {
|
642
|
+
"content-type": 'application/json',
|
643
|
+
}
|
644
|
+
|
645
|
+
@client.call(
|
646
|
+
method: 'PATCH',
|
647
|
+
path: api_path,
|
648
|
+
headers: api_headers,
|
649
|
+
params: api_params,
|
650
|
+
response_type: Models::User
|
651
|
+
)
|
652
|
+
end
|
653
|
+
|
654
|
+
|
655
|
+
# Get the preferences as a key-value object for the currently logged in user.
|
656
|
+
#
|
657
|
+
#
|
658
|
+
# @return [Preferences]
|
659
|
+
def get_prefs()
|
660
|
+
api_path = '/account/prefs'
|
661
|
+
|
662
|
+
api_params = {
|
663
|
+
}
|
664
|
+
|
665
|
+
api_headers = {
|
666
|
+
"content-type": 'application/json',
|
667
|
+
}
|
668
|
+
|
669
|
+
@client.call(
|
670
|
+
method: 'GET',
|
671
|
+
path: api_path,
|
672
|
+
headers: api_headers,
|
673
|
+
params: api_params,
|
674
|
+
response_type: Models::Preferences
|
675
|
+
)
|
676
|
+
end
|
677
|
+
|
678
|
+
|
679
|
+
# Update currently logged in user account preferences. The object you pass is
|
680
|
+
# stored as is, and replaces any previous value. The maximum allowed prefs
|
681
|
+
# size is 64kB and throws error if exceeded.
|
682
|
+
#
|
683
|
+
# @param [Hash] prefs Prefs key-value JSON object.
|
684
|
+
#
|
685
|
+
# @return [User]
|
686
|
+
def update_prefs(prefs:)
|
687
|
+
api_path = '/account/prefs'
|
688
|
+
|
689
|
+
if prefs.nil?
|
690
|
+
raise Appwrite::Exception.new('Missing required parameter: "prefs"')
|
691
|
+
end
|
692
|
+
|
693
|
+
api_params = {
|
694
|
+
prefs: prefs,
|
695
|
+
}
|
696
|
+
|
697
|
+
api_headers = {
|
698
|
+
"content-type": 'application/json',
|
699
|
+
}
|
700
|
+
|
701
|
+
@client.call(
|
702
|
+
method: 'PATCH',
|
703
|
+
path: api_path,
|
704
|
+
headers: api_headers,
|
705
|
+
params: api_params,
|
706
|
+
response_type: Models::User
|
707
|
+
)
|
708
|
+
end
|
709
|
+
|
710
|
+
|
711
|
+
# Sends the user an email with a temporary secret key for password reset.
|
712
|
+
# When the user clicks the confirmation link he is redirected back to your
|
713
|
+
# app password reset URL with the secret key and email address values
|
714
|
+
# attached to the URL query string. Use the query string params to submit a
|
715
|
+
# request to the [PUT
|
716
|
+
# /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
|
717
|
+
# endpoint to complete the process. The verification link sent to the user's
|
718
|
+
# email address is valid for 1 hour.
|
719
|
+
#
|
720
|
+
# @param [String] email User email.
|
721
|
+
# @param [String] url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
722
|
+
#
|
723
|
+
# @return [Token]
|
724
|
+
def create_recovery(email:, url:)
|
725
|
+
api_path = '/account/recovery'
|
726
|
+
|
727
|
+
if email.nil?
|
728
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
729
|
+
end
|
730
|
+
|
731
|
+
if url.nil?
|
732
|
+
raise Appwrite::Exception.new('Missing required parameter: "url"')
|
733
|
+
end
|
734
|
+
|
735
|
+
api_params = {
|
736
|
+
email: email,
|
737
|
+
url: url,
|
738
|
+
}
|
739
|
+
|
740
|
+
api_headers = {
|
741
|
+
"content-type": 'application/json',
|
742
|
+
}
|
743
|
+
|
744
|
+
@client.call(
|
745
|
+
method: 'POST',
|
746
|
+
path: api_path,
|
747
|
+
headers: api_headers,
|
748
|
+
params: api_params,
|
749
|
+
response_type: Models::Token
|
750
|
+
)
|
751
|
+
end
|
752
|
+
|
753
|
+
|
754
|
+
# Use this endpoint to complete the user account password reset. Both the
|
755
|
+
# **userId** and **secret** arguments will be passed as query parameters to
|
756
|
+
# the redirect URL you have provided when sending your request to the [POST
|
757
|
+
# /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
|
758
|
+
# endpoint.
|
759
|
+
#
|
760
|
+
# Please note that in order to avoid a [Redirect
|
761
|
+
# Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
762
|
+
# the only valid redirect URLs are the ones from domains you have set when
|
763
|
+
# adding your platforms in the console interface.
|
764
|
+
#
|
765
|
+
# @param [String] user_id User ID.
|
766
|
+
# @param [String] secret Valid reset token.
|
767
|
+
# @param [String] password New user password. Must be between 8 and 256 chars.
|
768
|
+
#
|
769
|
+
# @return [Token]
|
770
|
+
def update_recovery(user_id:, secret:, password:)
|
771
|
+
api_path = '/account/recovery'
|
772
|
+
|
773
|
+
if user_id.nil?
|
774
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
775
|
+
end
|
776
|
+
|
777
|
+
if secret.nil?
|
778
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
779
|
+
end
|
780
|
+
|
781
|
+
if password.nil?
|
782
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
783
|
+
end
|
784
|
+
|
785
|
+
api_params = {
|
786
|
+
userId: user_id,
|
787
|
+
secret: secret,
|
788
|
+
password: password,
|
789
|
+
}
|
790
|
+
|
791
|
+
api_headers = {
|
792
|
+
"content-type": 'application/json',
|
793
|
+
}
|
794
|
+
|
795
|
+
@client.call(
|
796
|
+
method: 'PUT',
|
797
|
+
path: api_path,
|
798
|
+
headers: api_headers,
|
799
|
+
params: api_params,
|
800
|
+
response_type: Models::Token
|
801
|
+
)
|
802
|
+
end
|
803
|
+
|
804
|
+
|
805
|
+
# Get the list of active sessions across different devices for the currently
|
806
|
+
# logged in user.
|
807
|
+
#
|
808
|
+
#
|
809
|
+
# @return [SessionList]
|
810
|
+
def list_sessions()
|
811
|
+
api_path = '/account/sessions'
|
812
|
+
|
813
|
+
api_params = {
|
814
|
+
}
|
815
|
+
|
816
|
+
api_headers = {
|
817
|
+
"content-type": 'application/json',
|
818
|
+
}
|
819
|
+
|
820
|
+
@client.call(
|
821
|
+
method: 'GET',
|
822
|
+
path: api_path,
|
823
|
+
headers: api_headers,
|
824
|
+
params: api_params,
|
825
|
+
response_type: Models::SessionList
|
826
|
+
)
|
827
|
+
end
|
828
|
+
|
829
|
+
|
830
|
+
# Delete all sessions from the user account and remove any sessions cookies
|
831
|
+
# from the end client.
|
832
|
+
#
|
833
|
+
#
|
834
|
+
# @return []
|
835
|
+
def delete_sessions()
|
836
|
+
api_path = '/account/sessions'
|
837
|
+
|
838
|
+
api_params = {
|
839
|
+
}
|
840
|
+
|
841
|
+
api_headers = {
|
842
|
+
"content-type": 'application/json',
|
843
|
+
}
|
844
|
+
|
845
|
+
@client.call(
|
846
|
+
method: 'DELETE',
|
847
|
+
path: api_path,
|
848
|
+
headers: api_headers,
|
849
|
+
params: api_params,
|
850
|
+
)
|
851
|
+
end
|
852
|
+
|
853
|
+
|
854
|
+
# Use this endpoint to allow a new user to register an anonymous account in
|
855
|
+
# your project. This route will also create a new session for the user. To
|
856
|
+
# allow the new user to convert an anonymous account to a normal account, you
|
857
|
+
# need to update its [email and
|
858
|
+
# password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
|
859
|
+
# or create an [OAuth2
|
860
|
+
# session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
|
861
|
+
#
|
862
|
+
#
|
863
|
+
# @return [Session]
|
864
|
+
def create_anonymous_session()
|
865
|
+
api_path = '/account/sessions/anonymous'
|
866
|
+
|
867
|
+
api_params = {
|
868
|
+
}
|
869
|
+
|
870
|
+
api_headers = {
|
871
|
+
"content-type": 'application/json',
|
872
|
+
}
|
873
|
+
|
874
|
+
@client.call(
|
875
|
+
method: 'POST',
|
876
|
+
path: api_path,
|
877
|
+
headers: api_headers,
|
878
|
+
params: api_params,
|
879
|
+
response_type: Models::Session
|
880
|
+
)
|
881
|
+
end
|
882
|
+
|
883
|
+
|
884
|
+
# Allow the user to login into their account by providing a valid email and
|
885
|
+
# password combination. This route will create a new session for the user.
|
886
|
+
#
|
887
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
888
|
+
# about session
|
889
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
890
|
+
#
|
891
|
+
# @param [String] email User email.
|
892
|
+
# @param [String] password User password. Must be at least 8 chars.
|
893
|
+
#
|
894
|
+
# @return [Session]
|
895
|
+
def create_email_password_session(email:, password:)
|
896
|
+
api_path = '/account/sessions/email'
|
897
|
+
|
898
|
+
if email.nil?
|
899
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
900
|
+
end
|
901
|
+
|
902
|
+
if password.nil?
|
903
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
904
|
+
end
|
905
|
+
|
906
|
+
api_params = {
|
907
|
+
email: email,
|
908
|
+
password: password,
|
909
|
+
}
|
910
|
+
|
911
|
+
api_headers = {
|
912
|
+
"content-type": 'application/json',
|
913
|
+
}
|
914
|
+
|
915
|
+
@client.call(
|
916
|
+
method: 'POST',
|
917
|
+
path: api_path,
|
918
|
+
headers: api_headers,
|
919
|
+
params: api_params,
|
920
|
+
response_type: Models::Session
|
921
|
+
)
|
922
|
+
end
|
923
|
+
|
924
|
+
|
925
|
+
# Use this endpoint to create a session from token. Provide the **userId**
|
926
|
+
# and **secret** parameters from the successful response of authentication
|
927
|
+
# flows initiated by token creation. For example, magic URL and phone login.
|
928
|
+
#
|
929
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
930
|
+
# @param [String] secret Valid verification token.
|
931
|
+
#
|
932
|
+
# @return [Session]
|
933
|
+
def update_magic_url_session(user_id:, secret:)
|
934
|
+
api_path = '/account/sessions/magic-url'
|
935
|
+
|
936
|
+
if user_id.nil?
|
937
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
938
|
+
end
|
939
|
+
|
940
|
+
if secret.nil?
|
941
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
942
|
+
end
|
943
|
+
|
944
|
+
api_params = {
|
945
|
+
userId: user_id,
|
946
|
+
secret: secret,
|
947
|
+
}
|
948
|
+
|
949
|
+
api_headers = {
|
950
|
+
"content-type": 'application/json',
|
951
|
+
}
|
952
|
+
|
953
|
+
@client.call(
|
954
|
+
method: 'PUT',
|
955
|
+
path: api_path,
|
956
|
+
headers: api_headers,
|
957
|
+
params: api_params,
|
958
|
+
response_type: Models::Session
|
959
|
+
)
|
960
|
+
end
|
961
|
+
|
962
|
+
|
963
|
+
# Use this endpoint to create a session from token. Provide the **userId**
|
964
|
+
# and **secret** parameters from the successful response of authentication
|
965
|
+
# flows initiated by token creation. For example, magic URL and phone login.
|
966
|
+
#
|
967
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
968
|
+
# @param [String] secret Valid verification token.
|
969
|
+
#
|
970
|
+
# @return [Session]
|
971
|
+
def update_phone_session(user_id:, secret:)
|
972
|
+
api_path = '/account/sessions/phone'
|
973
|
+
|
974
|
+
if user_id.nil?
|
975
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
976
|
+
end
|
977
|
+
|
978
|
+
if secret.nil?
|
979
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
980
|
+
end
|
981
|
+
|
982
|
+
api_params = {
|
983
|
+
userId: user_id,
|
984
|
+
secret: secret,
|
985
|
+
}
|
986
|
+
|
987
|
+
api_headers = {
|
988
|
+
"content-type": 'application/json',
|
989
|
+
}
|
990
|
+
|
991
|
+
@client.call(
|
992
|
+
method: 'PUT',
|
993
|
+
path: api_path,
|
994
|
+
headers: api_headers,
|
995
|
+
params: api_params,
|
996
|
+
response_type: Models::Session
|
997
|
+
)
|
998
|
+
end
|
999
|
+
|
1000
|
+
|
1001
|
+
# Use this endpoint to create a session from token. Provide the **userId**
|
1002
|
+
# and **secret** parameters from the successful response of authentication
|
1003
|
+
# flows initiated by token creation. For example, magic URL and phone login.
|
1004
|
+
#
|
1005
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1006
|
+
# @param [String] secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods.
|
1007
|
+
#
|
1008
|
+
# @return [Session]
|
1009
|
+
def create_session(user_id:, secret:)
|
1010
|
+
api_path = '/account/sessions/token'
|
1011
|
+
|
1012
|
+
if user_id.nil?
|
1013
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
if secret.nil?
|
1017
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
api_params = {
|
1021
|
+
userId: user_id,
|
1022
|
+
secret: secret,
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
api_headers = {
|
1026
|
+
"content-type": 'application/json',
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
@client.call(
|
1030
|
+
method: 'POST',
|
1031
|
+
path: api_path,
|
1032
|
+
headers: api_headers,
|
1033
|
+
params: api_params,
|
1034
|
+
response_type: Models::Session
|
1035
|
+
)
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
|
1039
|
+
# Use this endpoint to get a logged in user's session using a Session ID.
|
1040
|
+
# Inputting 'current' will return the current session being used.
|
1041
|
+
#
|
1042
|
+
# @param [String] session_id Session ID. Use the string 'current' to get the current device session.
|
1043
|
+
#
|
1044
|
+
# @return [Session]
|
1045
|
+
def get_session(session_id:)
|
1046
|
+
api_path = '/account/sessions/{sessionId}'
|
1047
|
+
.gsub('{sessionId}', session_id)
|
1048
|
+
|
1049
|
+
if session_id.nil?
|
1050
|
+
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
api_params = {
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
api_headers = {
|
1057
|
+
"content-type": 'application/json',
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
@client.call(
|
1061
|
+
method: 'GET',
|
1062
|
+
path: api_path,
|
1063
|
+
headers: api_headers,
|
1064
|
+
params: api_params,
|
1065
|
+
response_type: Models::Session
|
1066
|
+
)
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
|
1070
|
+
# Use this endpoint to extend a session's length. Extending a session is
|
1071
|
+
# useful when session expiry is short. If the session was created using an
|
1072
|
+
# OAuth provider, this endpoint refreshes the access token from the provider.
|
1073
|
+
#
|
1074
|
+
# @param [String] session_id Session ID. Use the string 'current' to update the current device session.
|
1075
|
+
#
|
1076
|
+
# @return [Session]
|
1077
|
+
def update_session(session_id:)
|
1078
|
+
api_path = '/account/sessions/{sessionId}'
|
1079
|
+
.gsub('{sessionId}', session_id)
|
1080
|
+
|
1081
|
+
if session_id.nil?
|
1082
|
+
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
1083
|
+
end
|
1084
|
+
|
1085
|
+
api_params = {
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
api_headers = {
|
1089
|
+
"content-type": 'application/json',
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
@client.call(
|
1093
|
+
method: 'PATCH',
|
1094
|
+
path: api_path,
|
1095
|
+
headers: api_headers,
|
1096
|
+
params: api_params,
|
1097
|
+
response_type: Models::Session
|
1098
|
+
)
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
|
1102
|
+
# Logout the user. Use 'current' as the session ID to logout on this device,
|
1103
|
+
# use a session ID to logout on another device. If you're looking to logout
|
1104
|
+
# the user on all devices, use [Delete
|
1105
|
+
# Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
|
1106
|
+
# instead.
|
1107
|
+
#
|
1108
|
+
# @param [String] session_id Session ID. Use the string 'current' to delete the current device session.
|
1109
|
+
#
|
1110
|
+
# @return []
|
1111
|
+
def delete_session(session_id:)
|
1112
|
+
api_path = '/account/sessions/{sessionId}'
|
1113
|
+
.gsub('{sessionId}', session_id)
|
1114
|
+
|
1115
|
+
if session_id.nil?
|
1116
|
+
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
api_params = {
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
api_headers = {
|
1123
|
+
"content-type": 'application/json',
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
@client.call(
|
1127
|
+
method: 'DELETE',
|
1128
|
+
path: api_path,
|
1129
|
+
headers: api_headers,
|
1130
|
+
params: api_params,
|
1131
|
+
)
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
|
1135
|
+
# Block the currently logged in user account. Behind the scene, the user
|
1136
|
+
# record is not deleted but permanently blocked from any access. To
|
1137
|
+
# completely delete a user, use the Users API instead.
|
567
1138
|
#
|
568
1139
|
#
|
569
1140
|
# @return [User]
|
@@ -587,6 +1158,202 @@ module Appwrite
|
|
587
1158
|
end
|
588
1159
|
|
589
1160
|
|
1161
|
+
# Sends the user an email with a secret key for creating a session. If the
|
1162
|
+
# provided user ID has not be registered, a new user will be created. Use the
|
1163
|
+
# returned user ID and secret and submit a request to the [POST
|
1164
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1165
|
+
# endpoint to complete the login process. The secret sent to the user's email
|
1166
|
+
# is valid for 15 minutes.
|
1167
|
+
#
|
1168
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1169
|
+
# about session
|
1170
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1171
|
+
#
|
1172
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1173
|
+
# @param [String] email User email.
|
1174
|
+
# @param [] phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.
|
1175
|
+
#
|
1176
|
+
# @return [Token]
|
1177
|
+
def create_email_token(user_id:, email:, phrase: nil)
|
1178
|
+
api_path = '/account/tokens/email'
|
1179
|
+
|
1180
|
+
if user_id.nil?
|
1181
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
if email.nil?
|
1185
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
api_params = {
|
1189
|
+
userId: user_id,
|
1190
|
+
email: email,
|
1191
|
+
phrase: phrase,
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
api_headers = {
|
1195
|
+
"content-type": 'application/json',
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
@client.call(
|
1199
|
+
method: 'POST',
|
1200
|
+
path: api_path,
|
1201
|
+
headers: api_headers,
|
1202
|
+
params: api_params,
|
1203
|
+
response_type: Models::Token
|
1204
|
+
)
|
1205
|
+
end
|
1206
|
+
|
1207
|
+
|
1208
|
+
# Sends the user an email with a secret key for creating a session. If the
|
1209
|
+
# provided user ID has not been registered, a new user will be created. When
|
1210
|
+
# the user clicks the link in the email, the user is redirected back to the
|
1211
|
+
# URL you provided with the secret key and userId values attached to the URL
|
1212
|
+
# query string. Use the query string parameters to submit a request to the
|
1213
|
+
# [POST
|
1214
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1215
|
+
# endpoint to complete the login process. The link sent to the user's email
|
1216
|
+
# address is valid for 1 hour. If you are on a mobile device you can leave
|
1217
|
+
# the URL parameter empty, so that the login completion will be handled by
|
1218
|
+
# your Appwrite instance by default.
|
1219
|
+
#
|
1220
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1221
|
+
# about session
|
1222
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1223
|
+
#
|
1224
|
+
#
|
1225
|
+
# @param [String] user_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1226
|
+
# @param [String] email User email.
|
1227
|
+
# @param [String] url URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
1228
|
+
# @param [] phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.
|
1229
|
+
#
|
1230
|
+
# @return [Token]
|
1231
|
+
def create_magic_url_token(user_id:, email:, url: nil, phrase: nil)
|
1232
|
+
api_path = '/account/tokens/magic-url'
|
1233
|
+
|
1234
|
+
if user_id.nil?
|
1235
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
if email.nil?
|
1239
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
api_params = {
|
1243
|
+
userId: user_id,
|
1244
|
+
email: email,
|
1245
|
+
url: url,
|
1246
|
+
phrase: phrase,
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
api_headers = {
|
1250
|
+
"content-type": 'application/json',
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
@client.call(
|
1254
|
+
method: 'POST',
|
1255
|
+
path: api_path,
|
1256
|
+
headers: api_headers,
|
1257
|
+
params: api_params,
|
1258
|
+
response_type: Models::Token
|
1259
|
+
)
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
|
1263
|
+
# Allow the user to login to their account using the OAuth2 provider of their
|
1264
|
+
# choice. Each OAuth2 provider should be enabled from the Appwrite console
|
1265
|
+
# first. Use the success and failure arguments to provide a redirect URL's
|
1266
|
+
# back to your app when login is completed.
|
1267
|
+
#
|
1268
|
+
# If authentication succeeds, `userId` and `secret` of a token will be
|
1269
|
+
# appended to the success URL as query parameters. These can be used to
|
1270
|
+
# create a new session using the [Create
|
1271
|
+
# session](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1272
|
+
# endpoint.
|
1273
|
+
#
|
1274
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1275
|
+
# about session
|
1276
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1277
|
+
#
|
1278
|
+
# @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
|
1279
|
+
# @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
1280
|
+
# @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
1281
|
+
# @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
|
1282
|
+
#
|
1283
|
+
# @return []
|
1284
|
+
def create_o_auth2_token(provider:, success: nil, failure: nil, scopes: nil)
|
1285
|
+
api_path = '/account/tokens/oauth2/{provider}'
|
1286
|
+
.gsub('{provider}', provider)
|
1287
|
+
|
1288
|
+
if provider.nil?
|
1289
|
+
raise Appwrite::Exception.new('Missing required parameter: "provider"')
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
api_params = {
|
1293
|
+
success: success,
|
1294
|
+
failure: failure,
|
1295
|
+
scopes: scopes,
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
api_headers = {
|
1299
|
+
"content-type": 'application/json',
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
@client.call(
|
1303
|
+
method: 'GET',
|
1304
|
+
path: api_path,
|
1305
|
+
headers: api_headers,
|
1306
|
+
params: api_params,
|
1307
|
+
response_type: "location"
|
1308
|
+
)
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
|
1312
|
+
# Sends the user an SMS with a secret key for creating a session. If the
|
1313
|
+
# provided user ID has not be registered, a new user will be created. Use the
|
1314
|
+
# returned user ID and secret and submit a request to the [POST
|
1315
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1316
|
+
# endpoint to complete the login process. The secret sent to the user's phone
|
1317
|
+
# is valid for 15 minutes.
|
1318
|
+
#
|
1319
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1320
|
+
# about session
|
1321
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1322
|
+
#
|
1323
|
+
# @param [String] user_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1324
|
+
# @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
|
1325
|
+
#
|
1326
|
+
# @return [Token]
|
1327
|
+
def create_phone_token(user_id:, phone:)
|
1328
|
+
api_path = '/account/tokens/phone'
|
1329
|
+
|
1330
|
+
if user_id.nil?
|
1331
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1332
|
+
end
|
1333
|
+
|
1334
|
+
if phone.nil?
|
1335
|
+
raise Appwrite::Exception.new('Missing required parameter: "phone"')
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
api_params = {
|
1339
|
+
userId: user_id,
|
1340
|
+
phone: phone,
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
api_headers = {
|
1344
|
+
"content-type": 'application/json',
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
@client.call(
|
1348
|
+
method: 'POST',
|
1349
|
+
path: api_path,
|
1350
|
+
headers: api_headers,
|
1351
|
+
params: api_params,
|
1352
|
+
response_type: Models::Token
|
1353
|
+
)
|
1354
|
+
end
|
1355
|
+
|
1356
|
+
|
590
1357
|
# Use this endpoint to send a verification message to your user email address
|
591
1358
|
# to confirm they are the valid owners of that address. Both the **userId**
|
592
1359
|
# and **secret** arguments will be passed as query parameters to the URL you
|