Skip to content

Instantly share code, notes, and snippets.

@taylorbrooks
Last active August 8, 2016 13:11
Show Gist options
  • Save taylorbrooks/1f0c72f32832ee4b36cce661d343abf0 to your computer and use it in GitHub Desktop.
Save taylorbrooks/1f0c72f32832ee4b36cce661d343abf0 to your computer and use it in GitHub Desktop.
Passwordless Login for Phoenix

I'd like to build an Elixir library for passwordless login.

Modeled after this post, with a few alterations: http://inaka.net/blog/2016/07/27/passwordless-login-with-phoenix

The library would generate (or provide) a number of things:

  1. A migration for a login_keys table with 3 columns: [email, key, created_at]
  2. HTML template for submitting an email
  3. Email template for mailing login key
  4. Session routes and controllers
  5. Cron to delete login keys older than n [minutes, hours, days]

Login Flow

Get login link via email
  1. User navigates to /login
  2. User submits their email to form that does a POST to /login_keys
  3. System searches in for user by email a. If no user found, return error b. If user found, step 3
  4. System creates login key for email
  5. System sends an email to user with unique link to login
Login to app
  1. User clicks link (/login_keys/:uuid)
  2. System looks for login_key in table a. If no login_key found, return error b. If login_key found, step 7
  3. System finds login key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment