Merge branch 'redirect_after_login' into 'master'
Redirect after login
This commit is contained in:
commit
5aaa35656e
7 changed files with 41 additions and 6 deletions
|
@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base
|
|||
flash[:alert] = "Your account is blocked. Retry when an admin has unblocked it."
|
||||
new_user_session_path
|
||||
else
|
||||
super
|
||||
@return_to || root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
6
app/controllers/users_sessions_controller.rb
Normal file
6
app/controllers/users_sessions_controller.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class UsersSessionsController < Devise::SessionsController
|
||||
def create
|
||||
@return_to = params[:return_to]
|
||||
super
|
||||
end
|
||||
end
|
|
@ -7,8 +7,8 @@
|
|||
= f.check_box :remember_me
|
||||
%span Remember me
|
||||
%div
|
||||
= hidden_field_tag 'return_to', params[:return_to]
|
||||
= f.submit "Sign in", class: "btn-create btn"
|
||||
|
||||
.pull-right
|
||||
= link_to "Forgot your password?", new_password_path(resource_name), class: "btn"
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
%i.icon-reorder
|
||||
|
||||
.pull-right.hidden-xs
|
||||
= link_to "Sign in", new_session_path(:user), class: 'btn btn-sign-in btn-new'
|
||||
= link_to "Sign in", new_session_path(:user, return_to: request.fullpath), class: 'btn btn-sign-in btn-new'
|
||||
|
||||
.navbar-collapse.collapse
|
||||
%ul.nav.navbar-nav
|
||||
%li.visible-xs
|
||||
= link_to "Sign in", new_session_path(:user)
|
||||
= link_to "Sign in", new_session_path(:user, return_to: request.fullpath)
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ Gitlab::Application.routes.draw do
|
|||
|
||||
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
|
||||
|
||||
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords}
|
||||
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :users_sessions }
|
||||
|
||||
#
|
||||
# Project Area
|
||||
|
|
|
@ -24,3 +24,10 @@ Feature: Project Redirects
|
|||
Given I sign in as a user
|
||||
When I visit project "Enterprise" page
|
||||
Then page status code should be 404
|
||||
|
||||
Scenario: I visit a public project without signing in
|
||||
When I visit project "Community" page
|
||||
And I should see project "Community" home page
|
||||
And I click on "Sign In"
|
||||
And Authenticate
|
||||
Then I should be redirected to "Community" page
|
||||
|
|
|
@ -31,5 +31,27 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
|
|||
project = Project.find_by(name: 'Community')
|
||||
visit project_path(project) + 'DoesNotExist'
|
||||
end
|
||||
|
||||
step 'I click on "Sign In"' do
|
||||
within '.pull-right' do
|
||||
click_link "Sign in"
|
||||
end
|
||||
end
|
||||
|
||||
step 'Authenticate' do
|
||||
admin = create(:admin)
|
||||
project = Project.find_by(name: 'Community')
|
||||
find(:xpath, "//input[@id='return_to']").set "/#{project.path_with_namespace}"
|
||||
fill_in "user_login", with: admin.email
|
||||
fill_in "user_password", with: admin.password
|
||||
click_button "Sign in"
|
||||
Thread.current[:current_user] = admin
|
||||
end
|
||||
|
||||
step 'I should be redirected to "Community" page' do
|
||||
project = Project.find_by(name: 'Community')
|
||||
page.current_path.should == "/#{project.path_with_namespace}"
|
||||
page.status_code.should == 200
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue