Module: Sinatra::Chowder

Defined in:
lib/sinatra/chowder.rb

Instance Method Summary collapse

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/sinatra/chowder.rb', line 9

def authorized?
  session[:current_user]
end

#current_userObject



5
6
7
# File 'lib/sinatra/chowder.rb', line 5

def current_user
  session[:current_user]
end

#loginObject



13
14
15
16
# File 'lib/sinatra/chowder.rb', line 13

def 
  session[:redirect_to] = request.path_info
  redirect request.script_name + '/login'
end

#logoutObject



18
19
20
# File 'lib/sinatra/chowder.rb', line 18

def logout
  session[:current_user] = nil
end

#require_userObject



22
23
24
# File 'lib/sinatra/chowder.rb', line 22

def require_user
   unless authorized?
end