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 :authenticated?
|
||||||
helper_method :admin?
|
helper_method :admin?
|
||||||
|
|
||||||
after_filter :store_location
|
def after_sign_in_path_for(resource)
|
||||||
|
sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
|
||||||
def store_location
|
if request.referer == sign_in_url
|
||||||
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
super
|
||||||
if (!request.fullpath.match("/users/") && !request.xhr?) # don't store ajax calls
|
else
|
||||||
session[:previous_url] = request.fullpath
|
stored_location_for(resource) || request.referer || root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
class RegistrationsController < Devise::RegistrationsController
|
class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
protected
|
protected
|
||||||
|
def after_sign_up_path_for(resource)
|
||||||
def after_sign_in_path_for(resource)
|
signed_in_root_path(resource)
|
||||||
session[:previous_url] || root_path
|
end
|
||||||
end
|
|
||||||
|
def after_update_path_for(resource)
|
||||||
def after_sign_up_path_for(resource)
|
signed_in_root_path(resource)
|
||||||
root_path
|
end
|
||||||
end
|
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>
|
||||||
<li class="accountListItem accountLogout">
|
<li class="accountListItem accountLogout">
|
||||||
<div class="accountIcon"></div>
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
@ -53,3 +53,5 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% # Rails.logger.info(stored_location_for(:user)) %>
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- Account / Sign in -->
|
<!-- Account / Sign in -->
|
||||||
|
<% if !(controller_name == "sessions" && action_name == "new") %>
|
||||||
<div class="sidebarAccount upperRightEl">
|
<div class="sidebarAccount upperRightEl">
|
||||||
<div class="sidebarAccountIcon">
|
<div class="sidebarAccountIcon">
|
||||||
<% if user && user.image %>
|
<% if user && user.image %>
|
||||||
|
@ -79,5 +80,6 @@
|
||||||
<%= render :partial => 'layouts/account' %>
|
<%= render :partial => 'layouts/account' %>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- end sidebarAccount -->
|
</div><!-- end sidebarAccount -->
|
||||||
|
<% end %>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div><!-- end upperRightUI -->
|
</div><!-- end upperRightUI -->
|
|
@ -1,7 +1,11 @@
|
||||||
require 'uservoice-ruby'
|
require 'uservoice-ruby'
|
||||||
|
|
||||||
def current_sso_token
|
def current_sso_token
|
||||||
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
|
if ENV['SSO_KEY']
|
||||||
:email => current_user.email
|
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
|
||||||
}, 300) # Default expiry time is 5 minutes = 300 seconds
|
:email => current_user.email
|
||||||
|
}, 300) # Default expiry time is 5 minutes = 300 seconds
|
||||||
|
else
|
||||||
|
@current_sso_token = ''
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,10 +1,6 @@
|
||||||
Metamaps::Application.routes.draw do
|
Metamaps::Application.routes.draw do
|
||||||
|
|
||||||
root to: 'main#home', via: :get
|
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
|
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/embed', to: 'maps#embed', via: :get, as: :embed
|
||||||
match 'maps/:id/contains', to: 'maps#contains', via: :get, as: :contains
|
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_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, :skip => [:sessions]
|
||||||
devise_scope :user do
|
|
||||||
get "sign_out", :to => "devise/sessions#destroy"
|
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
|
end
|
||||||
|
|
||||||
match 'user/updatemetacodes', to: 'users#updatemetacodes', via: :post, as: :updatemetacodes
|
match 'user/updatemetacodes', to: 'users#updatemetacodes', via: :post, as: :updatemetacodes
|
||||||
resources :users, except: [:index, :destroy]
|
resources :users, except: [:index, :destroy]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue