Sha256: 558fb05fd5b7445256a7825b51e2b66ad227781aee63d411c10289f240882659
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
module Fae class SetupController < ActionController::Base helper Fae::FormHelper before_action :check_roles layout 'devise' def first_user @option = Fae::Option.instance return show_404 if Fae::User.live_super_admins.present? @user = Fae::User.new end def create_first_user return show_401 if Fae::User.live_super_admins.present? @user = Fae::User.new(user_params) super_admin = Fae::Role.find_by_name('super admin') @user.role = super_admin @user.active = true if @user.save sign_in(@user) redirect_to fae.root_path else @option = Fae::Option.instance render action: 'first_user', error: t('fae.save_error') end end private def show_404 render template: 'fae/pages/error404.html.slim', layout: 'fae/error.html.slim', status: :not_found end def show_401 render template: 'fae/pages/error404.html.slim', layout: 'fae/error.html.slim', status: :unauthorized end def user_params params.require(:user).permit(:email, :first_name, :last_name, :password, :password_confirmation) end def check_roles if Fae::Role.all.empty? raise "Role 'super admin' does not exist in Fae::Role, run rake fae:seed_db" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fae-rails-1.6.0 | app/controllers/fae/setup_controller.rb |