Class: Trestle::Auth::Backends::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/trestle/auth/backends/base.rb

Direct Known Subclasses

Basic, Warden

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller:, request:, session:, cookies:) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/trestle/auth/backends/base.rb', line 7

def initialize(controller:, request:, session:, cookies:)
  @controller, @request, @session, @cookies = controller, request, session, cookies
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'lib/trestle/auth/backends/base.rb', line 5

def controller
  @controller
end

#cookiesObject (readonly)

Returns the value of attribute cookies.



5
6
7
# File 'lib/trestle/auth/backends/base.rb', line 5

def cookies
  @cookies
end

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/trestle/auth/backends/base.rb', line 5

def request
  @request
end

#sessionObject (readonly)

Returns the value of attribute session.



5
6
7
# File 'lib/trestle/auth/backends/base.rb', line 5

def session
  @session
end

Instance Method Details

#previous_locationObject

Returns (and deletes) the previously stored return location from the session.



22
23
24
# File 'lib/trestle/auth/backends/base.rb', line 22

def previous_location
  session.delete(:trestle_return_to)
end

#scopeObject

Default params scope to use for the login form.



12
13
14
# File 'lib/trestle/auth/backends/base.rb', line 12

def scope
  :user
end

#store_location(url) ⇒ Object

Stores the previous return location in the session to return to after logging in.



17
18
19
# File 'lib/trestle/auth/backends/base.rb', line 17

def store_location(url)
  session[:trestle_return_to] = url
end