Class: DatabasusRuby::Auth

Inherits:
Object
  • Object
show all
Includes:
Endpoint
Defined in:
lib/databasus_ruby/objects/auth.rb,
sig/databasus_ruby.rbs

Overview

Obtaining a token. Every other endpoint needs the JWT these methods return, so #signin and #signup install it on the client as api_key.

client.auth.(email: "me@example.com", password: "secret")
client.users.me.name

Read the token off the result if you want to keep it for a later client.

Instance Attribute Summary

Attributes included from Endpoint

#client

Instance Method Summary collapse

Methods included from Endpoint

#acknowledged, #build, #collection, #compact, #escape, #http_delete, #http_get, #http_post, #http_put, #initialize, #inspect, #object, #single_value, #with_default_workspace

Methods inherited from Object

#==, #[], #hash, #initialize, #inspect, #key?, #keys, #method_missing, #respond_to_missing?, #to_h

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DatabasusRuby::Object

Instance Method Details

#github_callback(code:, redirect_uri:) ⇒ Object

POST /auth/github/callback

Parameters:

  • code: (String)
  • redirect_uri: (String)

Returns:



34
35
36
# File 'lib/databasus_ruby/objects/auth.rb', line 34

def github_callback(code:, redirect_uri:)
  object(http_post("auth/github/callback", { code: code, redirectUri: redirect_uri }))
end

#google_callback(code:, redirect_uri:) ⇒ Object

POST /auth/google/callback

Parameters:

  • code: (String)
  • redirect_uri: (String)

Returns:



39
40
41
# File 'lib/databasus_ruby/objects/auth.rb', line 39

def google_callback(code:, redirect_uri:)
  object(http_post("auth/google/callback", { code: code, redirectUri: redirect_uri }))
end

#reset_password(email:, code:, new_password:) ⇒ Object

POST /users/reset-password

Parameters:

  • email: (String)
  • code: (String)
  • new_password: (String)

Returns:



52
53
54
# File 'lib/databasus_ruby/objects/auth.rb', line 52

def reset_password(email:, code:, new_password:)
  object(http_post("users/reset-password", { email: email, code: code, newPassword: new_password }))
end

#send_reset_password_code(email:, cloudflare_turnstile_token: nil) ⇒ Object

POST /users/send-reset-password-code

Parameters:

  • email: (String)
  • cloudflare_turnstile_token: (String, nil) (defaults to: nil)

Returns:



44
45
46
47
48
49
# File 'lib/databasus_ruby/objects/auth.rb', line 44

def send_reset_password_code(email:, cloudflare_turnstile_token: nil)
  object(http_post("users/send-reset-password-code", {
                     email: email,
                     cloudflareTurnstileToken: cloudflare_turnstile_token
                   }))
end

#signin(email:, password:, cloudflare_turnstile_token: nil) ⇒ Object

POST /users/signin

Parameters:

  • email: (String)
  • password: (String)
  • cloudflare_turnstile_token: (String, nil) (defaults to: nil)

Returns:



15
16
17
18
19
20
21
# File 'lib/databasus_ruby/objects/auth.rb', line 15

def (email:, password:, cloudflare_turnstile_token: nil)
  authorize object(http_post("users/signin", {
                               email: email,
                               password: password,
                               cloudflareTurnstileToken: cloudflare_turnstile_token
                             }))
end

#signup(email:, name:, password:, cloudflare_turnstile_token: nil) ⇒ Object

POST /users/signup

Parameters:

  • email: (String)
  • name: (String)
  • password: (String)
  • cloudflare_turnstile_token: (String, nil) (defaults to: nil)

Returns:



24
25
26
27
28
29
30
31
# File 'lib/databasus_ruby/objects/auth.rb', line 24

def (email:, name:, password:, cloudflare_turnstile_token: nil)
  authorize object(http_post("users/signup", {
                               email: email,
                               name: name,
                               password: password,
                               cloudflareTurnstileToken: cloudflare_turnstile_token
                             }))
end