Sha256: 55b657931dd38a36d1681d3ff9b1253b190342c5f874dfe2559a38a8de03872e
Contents?: true
Size: 997 Bytes
Versions: 3
Compression:
Stored size: 997 Bytes
Contents
module Refinery class UsersController < Devise::RegistrationsController # Protect these actions behind an admin login before_filter :redirect?, :only => [:new, :create] layout 'refinery/layouts/login' def new @user = User.new end # This method should only be used to create the first Refinery user. def create @user = User.new(params[:user]) if @user.create_first flash[:message] = "<h2>#{t('welcome', :scope => 'refinery.users.create', :who => @user.username).gsub(/\.$/, '')}.</h2>".html_safe sign_in(@user) redirect_back_or_default(refinery.admin_root_path) else render :new end end protected def redirect? if refinery_user? redirect_to refinery.admin_users_path elsif refinery_users_exist? redirect_to refinery.new_refinery_user_session_path end end def refinery_users_exist? Refinery::Role[:refinery].users.any? end end end
Version data entries
3 entries across 3 versions & 1 rubygems