Module: WorkOS::Passwordless
- Extended by:
- Client
- Defined in:
- lib/workos/passwordless.rb
Overview
The Passwordless module provides convenience methods for working with passwordless sessions including the WorkOS Magic Link. You’ll need a valid API key.
Class Method Summary collapse
-
.create_session(options) ⇒ Object
Create a Passwordless Session.
-
.send_session(session_id) ⇒ Object
Send a Passwordless Session via email.
Methods included from Client
client, delete_request, execute_request, get_request, handle_error_response, post_request, put_request, user_agent
Class Method Details
.create_session(options) ⇒ Object
Create a Passwordless Session.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/workos/passwordless.rb', line 34 def create_session() response = execute_request( request: post_request( path: '/passwordless/sessions', auth: true, body: , ), ) hash = JSON.parse(response.body) WorkOS::Types::PasswordlessSessionStruct.new( id: hash['id'], email: hash['email'], expires_at: Date.parse(hash['expires_at']), link: hash['link'], ) end |
.send_session(session_id) ⇒ Object
Send a Passwordless Session via email.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/workos/passwordless.rb', line 59 def send_session(session_id) response = execute_request( request: post_request( path: "/passwordless/sessions/#{session_id}/send", auth: true, ), ) JSON.parse(response.body) end |