Sha256: b630fa9e6efd625eeedee4438367bfcfb0719ecee09cd86aeb32f8fad2ff3a8f

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

class Gaku::Devise::RegistrationsController < Devise::RegistrationsController
  # helper Gaku::GakuHelper
  layout 'gaku/layouts/gaku'

  def set_up_admin_account
    resource = build_resource({})
    respond_with resource
  end

  def create
    build_resource(user_params)

    if resource.save
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_navigational_format?
        sign_up(resource_name, resource)
        respond_with resource, location: after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
        expire_session_data_after_sign_in!
        respond_with resource, location: after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      respond_with resource
    end
  end

  def create_admin
    build_resource(user_params)
    admin_role = Gaku::Role.where(name: 'Admin').first_or_create!
    resource.roles << admin_role

    if resource.save
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_navigational_format?
        sign_up(resource_name, resource)
        respond_with resource, location: after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
        expire_session_data_after_sign_in!
        respond_with resource, location: after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      respond_with resource
    end
  end

  protected

  def user_params
    params.require(:user).permit(user_attr)
  end

  def user_attr
    %i( username email password password_confirmation )
  end

end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_frontend-0.3.0 app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.3.0.pre.4 app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.3.0.pre.3 app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.3.0.pre.2 app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.3.0.pre.1 app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.3.0.pre.0 app/controllers/gaku/devise/registrations_controller.rb
gaku-0.2.4 frontend/app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.2.4 app/controllers/gaku/devise/registrations_controller.rb
gaku-0.2.3 frontend/app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.2.3 app/controllers/gaku/devise/registrations_controller.rb
gaku-0.2.2 frontend/app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.2.2 app/controllers/gaku/devise/registrations_controller.rb
gaku-0.2.1 frontend/app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.2.1 app/controllers/gaku/devise/registrations_controller.rb
gaku-0.2.0 frontend/app/controllers/gaku/devise/registrations_controller.rb
gaku_frontend-0.2.0 app/controllers/gaku/devise/registrations_controller.rb