From c0564fff147272020b363d5b7dcefc563af49f18 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 00:51:06 -0500 Subject: [PATCH] Added Dashboard Integration and Authentication - Signin and Signup views still not being shown and defaulting to default --- .../controllers/registrations_controller.rb | 16 +- .../app/views/dashboard/index.html.erb | 189 ++++++------------ .../views/users/registrations/new.html.erb | 2 +- 3 files changed, 77 insertions(+), 130 deletions(-) diff --git a/Pearlception/app/controllers/registrations_controller.rb b/Pearlception/app/controllers/registrations_controller.rb index 48c6d01..8ce31be 100644 --- a/Pearlception/app/controllers/registrations_controller.rb +++ b/Pearlception/app/controllers/registrations_controller.rb @@ -1,13 +1,23 @@ class RegistrationsController < Devise::RegistrationsController include ApplicationHelper - protected + #protected def create - super binding.pry + @user = User.new(sign_up_params) + if !@user.admin? + #search by company token given by one of pearlception admins to the company + #and look up comany_id # + @user.company_id = 0 + else + @user.company_id = -1 + end + @user.save + sign_in @user + redirect_to "/" end def sign_up_params - params.require(:user).permit(:company_id, :email, :password, :password_confirmation) + params.require(:user).permit(:email, :password, :password_confirmation, :company_id) end end diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index be38ebf..0c6abd8 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -10,23 +10,23 @@ - Pearlception + Pearlception @@ -35,10 +35,15 @@
diff --git a/Pearlception/app/views/users/registrations/new.html.erb b/Pearlception/app/views/users/registrations/new.html.erb index 06ef1ad..64d7da6 100644 --- a/Pearlception/app/views/users/registrations/new.html.erb +++ b/Pearlception/app/views/users/registrations/new.html.erb @@ -1,4 +1,4 @@ -

Sign up

+

Sign up!

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %>