Use sorcery for logins

This gives us more flexibility and allows us to use password authentication
later. Also we don't need to build the login functionality ourself.
This commit is contained in:
2020-04-13 14:59:07 +02:00
parent 73c184a4a0
commit c478cfc7af
12 changed files with 642 additions and 62 deletions

View File

@@ -0,0 +1,15 @@
class SorceryCore < ActiveRecord::Migration[6.0]
def change
add_column :users, :crypted_password, :string
add_column :users, :salt, :string
add_column :users, :magic_login_token, :string
add_column :users, :magic_login_token_expires_at, :datetime
add_column :users, :magic_login_email_sent_at, :datetime
add_column :authentications, :provider, :string, null: false
add_column :authentications, :uid, :string, null: false
add_index :users, :magic_login_token
add_index :users, :email, unique: true
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_04_12_214304) do
ActiveRecord::Schema.define(version: 2020_04_13_101920) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -45,6 +45,8 @@ ActiveRecord::Schema.define(version: 2020_04_12_214304) do
t.datetime "updated_at", precision: 6, null: false
t.text "access_token_ciphertext"
t.text "refresh_token_ciphertext"
t.string "provider"
t.string "uid"
end
create_table "forms", force: :cascade do |t|
@@ -74,6 +76,13 @@ ActiveRecord::Schema.define(version: 2020_04_12_214304) do
t.string "google_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "crypted_password"
t.string "salt"
t.string "magic_login_token"
t.datetime "magic_login_token_expires_at"
t.datetime "magic_login_email_sent_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["magic_login_token"], name: "index_users_on_magic_login_token"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"