Module: StompBox::Authentication

Defined in:
app/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(username, password) ⇒ Object



31
32
33
34
35
36
37
# File 'app/authentication.rb', line 31

def authenticate(username, password)
  return false if username.nil? || password.nil?
  authenticator = TorqueBox::Authentication.default
  authenticator.authenticate(username, password) do
    session[:user] = username
  end
end

#authenticated?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/authentication.rb', line 27

def authenticated?
  !session[:user].nil?
end

#login_pathObject



23
24
25
# File 'app/authentication.rb', line 23

def 
  "#{request.script_name}/login"
end

#logoutObject



49
50
51
52
# File 'app/authentication.rb', line 49

def logout
  session[:user] = nil
  redirect 
end

#require_authenticationObject



43
44
45
46
47
# File 'app/authentication.rb', line 43

def require_authentication
  return if request.env['SKIP_AUTH']
  return if authenticated?
  redirect  
end

#skip_authenticationObject



39
40
41
# File 'app/authentication.rb', line 39

def skip_authentication
  request.env['SKIP_AUTH'] = true
end