Sha256: d8cf74790a5ea0b266ce5bfe8ce2582c20e952d27e12ba503ef3323c01b6440d

Contents?: true

Size: 941 Bytes

Versions: 7

Compression:

Stored size: 941 Bytes

Contents

class UsersController < ApplicationController
  
  before_filter :authenticate, only: 'index'
  before_filter :authenticate_with_admin, except: ['new', 'create']
  
  def index
    @users = User.by_recent
    render layout: 'admin'
  end

  def new
    @user = User.new
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      cookies[:auth_token] = @user.auth_token
      redirect_to session[:target_page] || safe_root_url, notice: t('authentication.signup_confirmation')
      session[:target_page] = nil
    else
      render "new"
    end
  end
  
  def make_admin
    user = User.find(params[:id])
    user.admin = true
    user.save
    redirect_to users_path, notice: t('authentication.admin_enabled_confirmation')
  end
  
  def remove_admin
    user = User.find(params[:id])
    user.admin = false
    user.save
    redirect_to users_path, notice: t('authentication.admin_disabled_confirmation')
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tkh_authentication-0.1.2 app/controllers/users_controller.rb
tkh_authentication-0.1.1 app/controllers/users_controller.rb
tkh_authentication-0.1 app/controllers/users_controller.rb
tkh_authentication-0.0.12 app/controllers/users_controller.rb
tkh_authentication-0.0.11 app/controllers/users_controller.rb
tkh_authentication-0.0.10 app/controllers/users_controller.rb
tkh_authentication-0.0.9 app/controllers/users_controller.rb