Skip to content

Commit

Permalink
Merge pull request #826 from sparc-request/jjh-create-user-sesh
Browse files Browse the repository at this point in the history
Logging in shouldn't empty cart, and creating a new user shouldn't cause an error [#136266959] [#136270759]
  • Loading branch information
jleonardw9 committed Dec 16, 2016
2 parents 18167e4 + 15beab0 commit 0e87651
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def initialize_service_request
create_new_service_request
end
elsif params[:controller] == 'devise/sessions' || params[:controller] == 'identities/sessions'
if params[:id]
use_existing_service_request(params[:id])
if params[:id] || params[:service_request_id]
use_existing_service_request(params[:id] || params[:service_request_id])
else
@service_request = ServiceRequest.new(status: 'first_draft')
@service_request.save(validate: false)
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/identities/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class Identities::SessionsController < Devise::SessionsController
def new
# Redirect url after login.
@redirect_to = params[:redirect_to]
super
end

def create
self.resource = resource_class.new(sign_in_params)

# Pass redirect url to ApplicationController for redirect.
store_location_for(resource, params[:redirect_to])
store_location_for(resource, catalog_service_request_path(@service_request.id))
super
end
end
1 change: 1 addition & 0 deletions app/views/devise/registrations/_new_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#sign-up-form
= form_for resource, as: resource_name, url: registration_path(resource_name) do |f|
= hidden_field_tag :service_request_id, service_request.id
- if resource.errors.any?
= render 'shared/modal_errors', errors: resource.errors
.form-group.field
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
.col-sm-6
%h1.page-header.text-center
= t(:devise)[:registrations][:header]
= render 'new_form'
= render 'new_form', service_request: @service_request
.col-sm-3
2 changes: 1 addition & 1 deletion app/views/devise/sessions/_login_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.hidden#login-form
= form_for resource, as: resource_name, url: session_path(resource_name), role: 'form' do |f|
= hidden_field_tag :redirect_to, redirect_to
= hidden_field_tag :service_request_id, service_request.id
.form-group
= f.label :ldap_uid, t(:devise)[:sessions][:login]
= f.text_field :ldap_uid, autofocus: true, class: 'form-control'
Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
%a.btn.btn-primary.standard-login-button
= t(:devise)[:sessions][:other_users]
.form-group.sign-up-button
= link_to t(:devise)[:sessions][:sign_up], new_identity_registration_path
= link_to t(:devise)[:sessions][:sign_up], new_identity_registration_path(service_request_id: @service_request.id)
.form-group.return-button
%a.btn.btn-primary{ href: root_path }
= t(:devise)[:sessions][:return]
= render 'login_form', redirect_to: @redirect_to
= render 'login_form', service_request: @service_request
.col-md-3
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
= I18n.t('proper.navbar.logged_in', email: current_user.email)
= link_to t(:proper)[:navbar][:logout], destroy_identity_session_path, method: :delete, class: 'btn btn-warning'
- else
= link_to t(:proper)[:navbar][:login], new_identity_session_path(redirect_to: catalog_service_request_path(id: service_request.id)), class: 'btn btn-primary', id: 'login-link'
= link_to t(:proper)[:navbar][:login], new_identity_session_path(service_request_id: service_request.id), class: 'btn btn-primary', id: 'login-link'

0 comments on commit 0e87651

Please sign in to comment.