fixed sign in redirects
This commit is contained in:
parent
9ba6daec90
commit
629a6a4172
8 changed files with 51 additions and 28 deletions
|
@ -8,12 +8,12 @@ class ApplicationController < ActionController::Base
|
|||
helper_method :authenticated?
|
||||
helper_method :admin?
|
||||
|
||||
after_filter :store_location
|
||||
|
||||
def store_location
|
||||
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
||||
if (!request.fullpath.match("/users/") && !request.xhr?) # don't store ajax calls
|
||||
session[:previous_url] = request.fullpath
|
||||
def after_sign_in_path_for(resource)
|
||||
sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
|
||||
if request.referer == sign_in_url
|
||||
super
|
||||
else
|
||||
stored_location_for(resource) || request.referer || root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
class RegistrationsController < Devise::RegistrationsController
|
||||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
protected
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
session[:previous_url] || root_path
|
||||
end
|
||||
|
||||
def after_sign_up_path_for(resource)
|
||||
root_path
|
||||
end
|
||||
|
||||
end
|
||||
def after_sign_up_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
|
||||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
end
|
6
app/controllers/users/passwords_controller.rb
Normal file
6
app/controllers/users/passwords_controller.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class Users::PasswordsController < Devise::PasswordsController
|
||||
protected
|
||||
def after_resetting_password_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
end
|
10
app/controllers/users/registrations_controller.rb
Normal file
10
app/controllers/users/registrations_controller.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
protected
|
||||
def after_sign_up_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
|
||||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
end
|
|
@ -24,7 +24,7 @@
|
|||
</li>
|
||||
<li class="accountListItem accountLogout">
|
||||
<div class="accountIcon"></div>
|
||||
<%= link_to "Sign Out", "/sign_out", id: "Logout", :data => { :bypass => 'true'} %>
|
||||
<%= link_to "Sign Out", "/logout", id: "Logout", :data => { :bypass => 'true'} %>
|
||||
</li>
|
||||
</ul>
|
||||
<% else %>
|
||||
|
@ -53,3 +53,5 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% # Rails.logger.info(stored_location_for(:user)) %>
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<% end %>
|
||||
|
||||
<!-- Account / Sign in -->
|
||||
<% if !(controller_name == "sessions" && action_name == "new") %>
|
||||
<div class="sidebarAccount upperRightEl">
|
||||
<div class="sidebarAccountIcon">
|
||||
<% if user && user.image %>
|
||||
|
@ -79,5 +80,6 @@
|
|||
<%= render :partial => 'layouts/account' %>
|
||||
</div>
|
||||
</div><!-- end sidebarAccount -->
|
||||
<% end %>
|
||||
<div class="clearfloat"></div>
|
||||
</div><!-- end upperRightUI -->
|
|
@ -1,7 +1,11 @@
|
|||
require 'uservoice-ruby'
|
||||
|
||||
def current_sso_token
|
||||
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
|
||||
:email => current_user.email
|
||||
}, 300) # Default expiry time is 5 minutes = 300 seconds
|
||||
if ENV['SSO_KEY']
|
||||
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
|
||||
:email => current_user.email
|
||||
}, 300) # Default expiry time is 5 minutes = 300 seconds
|
||||
else
|
||||
@current_sso_token = ''
|
||||
end
|
||||
end
|
|
@ -1,10 +1,6 @@
|
|||
Metamaps::Application.routes.draw do
|
||||
|
||||
root to: 'main#home', via: :get
|
||||
|
||||
devise_scope :user do
|
||||
get "join" => "devise/registrations#new"
|
||||
end
|
||||
|
||||
match 'request', to: 'main#requestinvite', via: :get, as: :request
|
||||
|
||||
|
@ -31,10 +27,15 @@ Metamaps::Application.routes.draw do
|
|||
match 'maps/:id/embed', to: 'maps#embed', via: :get, as: :embed
|
||||
match 'maps/:id/contains', to: 'maps#contains', via: :get, as: :contains
|
||||
|
||||
devise_for :users, :controllers => { :registrations => "registrations" }, :path_names => { :sign_in => 'login', :sign_out => 'logout' }
|
||||
devise_scope :user do
|
||||
get "sign_out", :to => "devise/sessions#destroy"
|
||||
devise_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, :skip => [:sessions]
|
||||
|
||||
devise_scope :user do
|
||||
get 'login' => 'devise/sessions#new', :as => :new_user_session
|
||||
post 'login' => 'devise/sessions#create', :as => :user_session
|
||||
get 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session
|
||||
get 'join' => 'devise/registrations#new', :as => :new_user_registration
|
||||
end
|
||||
|
||||
match 'user/updatemetacodes', to: 'users#updatemetacodes', via: :post, as: :updatemetacodes
|
||||
resources :users, except: [:index, :destroy]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue