mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
Merged branch User-Sign-In-Sign-Up into master
This commit is contained in:
commit
ac0ab198cb
@ -2,15 +2,24 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
#protected
|
#protected
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
binding.pry
|
|
||||||
@user = User.new(sign_up_params)
|
@user = User.new(sign_up_params)
|
||||||
if !@user.admin?
|
|
||||||
#search by company token given by one of pearlception admins to the company
|
if params[:company_serial]
|
||||||
#and look up comany_id #
|
params.require(:user).permit(:company_id)
|
||||||
@user.company_id = 0
|
company = Company.find_by(company_token: params[:company_serial])
|
||||||
|
|
||||||
|
if company
|
||||||
|
@user.company_id = company.id
|
||||||
|
if company.company_name == "IVA"
|
||||||
|
@user.admin = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@user.company_id = -1
|
|
||||||
end
|
end
|
||||||
@user.save
|
@user.save
|
||||||
sign_in @user
|
sign_in @user
|
||||||
@ -18,6 +27,6 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign_up_params
|
def sign_up_params
|
||||||
params.require(:user).permit(:email, :password, :password_confirmation, :company_id)
|
params.require(:user).permit(:email, :password, :password_confirmation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
</ul> -->
|
</ul> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||||
<h1 class="page-header">Pearlception Dashboard</h1>
|
<h1 class="page-header"><strong><%= current_user.admin? ? "" : Company.find_by(id: current_user.company_id).company_name %></strong> Pearlception Dashboard</h1>
|
||||||
|
|
||||||
<!-- <div class="row placeholders">
|
<!-- <div class="row placeholders">
|
||||||
<div class="col-xs-6 col-sm-3 placeholder">
|
<div class="col-xs-6 col-sm-3 placeholder">
|
||||||
|
|||||||
33
Pearlception/app/views/registrations/new.html.erb
Normal file
33
Pearlception/app/views/registrations/new.html.erb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<h2>Sign up!</h2>
|
||||||
|
|
||||||
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||||
|
<%= devise_error_messages! %>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :company_Serial %><br />
|
||||||
|
<%= text_field_tag :company_serial, params[:company_serial], class: 'form-control center-text', placeholder: "XXXXX-XXXXXX-XXXXX-XXXX" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :email %><br />
|
||||||
|
<%= f.email_field :email, autofocus: true, class: 'form-control center-text', placeholder: "example@test.com" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :password %>
|
||||||
|
<% if @minimum_password_length %>
|
||||||
|
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||||
|
<% end %><br />
|
||||||
|
<%= f.password_field :password, autocomplete: "off", class: 'form-control center-text', placeholder: "password" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :password_Confirmation %><br />
|
||||||
|
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control center-text', placeholder: "confirm password" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions center">
|
||||||
|
<%= f.submit "Sign up", class: "btn" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render "users/shared/links" %>
|
||||||
Loading…
x
Reference in New Issue
Block a user