app/controllers/users_controller.rb in tkh_authentication-0.0.8 vs app/controllers/users_controller.rb in tkh_authentication-0.0.9
- old
+ new
@@ -1,9 +1,9 @@
class UsersController < ApplicationController
before_filter :authenticate, only: 'index'
- before_filter :authenticate_with_admin, only: 'index'
+ before_filter :authenticate_with_admin, except: ['new', 'create']
def index
@users = User.by_recent
render layout: 'admin'
end
@@ -19,8 +19,22 @@
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