From cdb330418b255b136813563eeb63bf2f34c92a9f Mon Sep 17 00:00:00 2001 From: Ivan Kocienski Date: Tue, 31 Jan 2023 12:03:44 +0000 Subject: [PATCH] User seed migration authenticates admin user Sends invitation, accepts invitation. Now you can log in with `admin@lvh.me` and `password`. --- db/seeds/001_users.rb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/db/seeds/001_users.rb b/db/seeds/001_users.rb index 264e5eb05..4c2011d44 100644 --- a/db/seeds/001_users.rb +++ b/db/seeds/001_users.rb @@ -1,10 +1,18 @@ # frozen_string_literal: true -User.find_or_create_by!( - email: 'admin@lvh.me' -) do |user| - user.password = 'password' - user.password_confirmation = 'password' -end.update!( - role: :root -) +module UserSeeder + module_function + + def run + user = User.find_or_create_by!(email: 'admin@lvh.me') do |u| + u.password = 'password' + u.password_confirmation = 'password' + u.role = :root + end + + user.invite! + user.accept_invitation! + end +end + +UserSeeder.run