Module: MicroAuth::ApplicationController::InstanceMethods

Defined in:
lib/micro_auth/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#admin?Boolean

Simple method to see if user is authenticated as admin.

Returns:

  • (Boolean)


18
19
20
# File 'lib/micro_auth/application_controller.rb', line 18

def admin?
	session[:admin] == true
end

#authenticateObject

Simple filter method to verify user is admin in controllers.



10
11
12
13
14
15
# File 'lib/micro_auth/application_controller.rb', line 10

def authenticate
	unless admin?
		session[:target] = request.path
		redirect_to , :alert => "You must be logged-in to view this page."
	end
end