Module: WackyCanvas::Authorization

Extended by:
ActiveSupport::Concern
Included in:
ActionController::Base
Defined in:
lib/wacky_canvas/authorization.rb

Instance Method Summary collapse

Instance Method Details

#authorizeObject



23
24
25
# File 'lib/wacky_canvas/authorization.rb', line 23

def authorize
  deny_access if signed_out?
end

#current_userObject

Finds the user from the Rack Wacky Canvas session



11
12
13
# File 'lib/wacky_canvas/authorization.rb', line 11

def current_user
  wacky_canvas_session.current_user
end

#deny_access(flash_message = nil) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/wacky_canvas/authorization.rb', line 27

def deny_access(flash_message = nil)
  flash[:notice] = flash_message if flash_message
  if signed_in?
    redirect_to(url_after_denied_access_when_signed_in)
  else
    redirect_to(url_after_denied_access_when_signed_out)
  end
end

#signed_in?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/wacky_canvas/authorization.rb', line 15

def signed_in?
  wacky_canvas_session.signed_in?
end

#signed_out?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/wacky_canvas/authorization.rb', line 19

def signed_out?
  !signed_in?
end