diff --git a/README.md b/README.md index 964b1d3..93544c3 100644 --- a/README.md +++ b/README.md @@ -25,43 +25,21 @@ See [Upgrading to Passwordless 1.0](docs/upgrading_to_1_0.md) for more details. ## Usage -Passwordless creates a single model called `Passwordless::Session`. It doesn't come with its own `User` model, it expects you to create one: +Passwordless creates a single model called `Passwordless::Session`, so it doesn't come with its own user model. Instead, it expects you to provide one, with an email field in place. If you don't yet have a user model, check out the wiki on [creating the user model](https://github.com/mikker/passwordless/wiki/Creating-the-user-model). -```sh -$ bin/rails generate model User email -``` - -Then specify which field on your `User` record is the email field with: +Enable Passwordless on your user model by pointing it to the email field: ```ruby class User < ApplicationRecord - validates :email, - presence: true, - uniqueness: { case_sensitive: false }, - format: { with: URI::MailTo::EMAIL_REGEXP } - - passwordless_with :email # <-- here! -end -``` - -You might want to update the generated migration file to include db-level constraints similar to the model validation above: - -```ruby -class CreateUsers < ActiveRecord::Migration[7.0] - def change - create_table :users do |t| - t.string :email, null: false - - t.index 'LOWER(email)', unique: true, name: 'index_users_on_lowercase_email' - - t.timestamps - end - end + # your other code.. + + passwordless_with :email # <-- here! this needs to be a column in `users` table + + # more of your code.. end ``` - -Finally, mount the engine in your routes: +Then mount the engine in your routes: ```ruby Rails.application.routes.draw do