Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom redirect locations #239

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/passwordless/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class SessionsController < Passwordless.config.parent_controller.constantize
# renders sessions/new.html.erb.
def new
@session = Session.new
unless params[:redirect_to].nil?
save_passwordless_redirect_location! authenticatable_class, params[:redirect_to]
end
end

# post '/:resource/sign_in'
Expand Down
6 changes: 4 additions & 2 deletions lib/passwordless/controller_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ def sign_out(authenticatable_class)
# Saves request.original_url as the redirect location for a
# passwordless Model.
# @param (see #authenticate_by_session)
# @param url [String] the url to redirect to
# @return [String] the redirect url that was just saved.
def save_passwordless_redirect_location!(authenticatable_class)
session[redirect_session_key(authenticatable_class)] = request.original_url
def save_passwordless_redirect_location!(authenticatable_class, url=nil)
url = request.original_url if url.nil?
set_passwordless_redirect_location! url
StevenClontz marked this conversation as resolved.
Show resolved Hide resolved
end

# Resets the redirect_location to root_path by deleting the redirect_url
Expand Down
Loading