Merge pull request #869 from consul/cancel-login

includes a "cancel" option when logging in via omniauth
This commit is contained in:
Juanjo Bazán
2016-02-03 12:09:07 +01:00
6 changed files with 25 additions and 3 deletions

View File

@@ -82,9 +82,7 @@ class ApplicationController < ActionController::Base
end
def ensure_signup_complete
if user_signed_in? &&
current_user.registering_with_oauth &&
%w(finish_signup do_finish_signup).exclude?(action_name)
if user_signed_in? && !devise_controller? && current_user.registering_with_oauth
redirect_to finish_signup_path
end
end

View File

@@ -16,4 +16,7 @@
<% end %>
<%= f.submit t("devise_views.users.registrations.new.submit"), class: 'button radius expand' %>
<div class="text-center">
<%= link_to t("devise_views.users.registrations.new.cancel"), destroy_user_session_path, class: 'delete', method: :delete %>
</div>
<% end %>

View File

@@ -107,6 +107,7 @@ en:
update_submit: Update
waiting_for: 'Awaiting confirmation of:'
new:
cancel: Cancel login
email_label: Email
organization_signup: Do you represent an organisation or collective? %{signup_link}
organization_signup_link: Sign up here

View File

@@ -107,6 +107,7 @@ es:
update_submit: Actualizar
waiting_for: 'Esperando confirmación de:'
new:
cancel: Cancelar login
email_label: Email
organization_signup: "¿Representas a una organización / colectivo? %{signup_link}"
organization_signup_link: Regístrate aquí

View File

@@ -125,6 +125,21 @@ feature 'Users' do
expect(page).to have_field('user_email', with: 'manueladelascarmenas@example.com')
end
scenario 'Cancelling signup' do
OmniAuth.config.add_mock(:twitter, twitter_hash)
visit '/'
click_link 'Register'
click_link 'Sign up with Twitter'
expect(current_path).to eq(finish_signup_path)
click_link 'Cancel login'
visit '/'
expect_to_not_be_signed_in
end
scenario 'Sign in, user was already signed up with OAuth' do
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
create(:identity, uid: '12345', provider: 'twitter', user: user)

View File

@@ -116,6 +116,10 @@ module CommonActions
expect(find('.top-bar')).to have_content 'My account'
end
def expect_to_not_be_signed_in
expect(find('.top-bar')).to_not have_content 'My account'
end
def select_date(values, selector)
selector = selector[:from]
day, month, year = values.split("-")