mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
Fix merge conflict
This commit is contained in:
commit
129eff3821
61
Pearlception/.vscode/launch.json
vendored
Normal file
61
Pearlception/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
/*{
|
||||
"name": "Debug Local File",
|
||||
"type": "Ruby",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/main.rb"
|
||||
},
|
||||
{
|
||||
"name": "Listen for rdebug-ide",
|
||||
"type": "Ruby",
|
||||
"request": "attach",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"remoteHost": "127.0.0.1",
|
||||
"remotePort": "1234",
|
||||
"remoteWorkspaceRoot": "${workspaceRoot}"
|
||||
},*/
|
||||
{
|
||||
"name": "Rails server",
|
||||
"type": "Ruby",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/bin/rails",
|
||||
"args": [
|
||||
"server"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RSpec - all",
|
||||
"type": "Ruby",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/bin/rspec",
|
||||
"args": [
|
||||
"-I",
|
||||
"${workspaceRoot}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RSpec - active spec file only",
|
||||
"type": "Ruby",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/bin/rspec",
|
||||
"args": [
|
||||
"-I",
|
||||
"${workspaceRoot}",
|
||||
"${file}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cucumber",
|
||||
"type": "Ruby",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/bin/cucumber"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
protected
|
||||
protected
|
||||
|
||||
def authenticate_user
|
||||
if session[:user_id]
|
||||
# set current user object to @current_user object variable
|
||||
@ -11,6 +12,7 @@ class ApplicationController < ActionController::Base
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def save_login_state
|
||||
if session[:user_id]
|
||||
redirect_to(:controller => 'sessions', :action => 'home')
|
||||
@ -19,4 +21,5 @@ class ApplicationController < ActionController::Base
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,19 +1,22 @@
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
include ApplicationHelper
|
||||
|
||||
#protected
|
||||
def new
|
||||
Apartment::Tenant.switch!
|
||||
end
|
||||
|
||||
|
||||
#Method to create a new User
|
||||
def create
|
||||
@user = User.new(sign_up_params)
|
||||
if params[:password] == nil || params[:password_confirmation] == nil
|
||||
user_params = sign_up_params
|
||||
@user = User.new(user_params)
|
||||
if user_params[:password] == "" || user_params[:password_confirmation] == ""
|
||||
puts "NO PASSWORD ERROR"
|
||||
flash[:error] = "Need a password to sign up"
|
||||
redirect_to '/signin'
|
||||
return
|
||||
end
|
||||
if params[:company_serial]
|
||||
params.require(:user).permit(:company_id)
|
||||
company = Company.find_by(company_token: params[:company_serial])
|
||||
if company
|
||||
@user.company_id = company.id
|
||||
@ -21,18 +24,38 @@ class RegistrationsController < Devise::RegistrationsController
|
||||
@user.admin = true
|
||||
end
|
||||
else
|
||||
flash[:alert] = "The serial key provided was invalid."
|
||||
redirect_to '/'
|
||||
end
|
||||
else
|
||||
flash[:alert] = "A company serial key must be provided to register."
|
||||
redirect_to '/'
|
||||
end
|
||||
|
||||
if @user == ""
|
||||
flash[:alert] = "Please provide a password to register with."
|
||||
redirect_to '/'
|
||||
else
|
||||
@user.save
|
||||
begin
|
||||
sign_in @user
|
||||
rescue
|
||||
flash[:error] = "Email already in use"
|
||||
redirect_to '/signin' and return
|
||||
end
|
||||
if !@user.admin
|
||||
Apartment::Tenant.switch(Company.find(@user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||
end
|
||||
redirect_to "/"
|
||||
redirect_to "/" and return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#Param checking method for creation of a new user
|
||||
def sign_up_params
|
||||
params.require(:user).permit(:email, :password, :password_confirmation)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
class SessionsController < Devise::RegistrationsController
|
||||
include ApplicationHelper
|
||||
#def new
|
||||
# Apartment::Tenant.switch!
|
||||
#end
|
||||
|
||||
def new
|
||||
super
|
||||
end
|
||||
|
||||
def create
|
||||
puts "NOW IN CREATE"
|
||||
params = sign_in_params
|
||||
@user = User.find_by(email: params[:email])
|
||||
if @user == nil || !@user.valid_password?(params[:password])
|
||||
redirect_to "/signin"
|
||||
return
|
||||
end
|
||||
super
|
||||
#Do we need this code below? It was never running before
|
||||
resource = warden.authenticate!(:scope => :user)
|
||||
sign_in(:user, resource)
|
||||
if !current_user.admin
|
||||
@ -12,4 +22,11 @@ class SessionsController < Devise::RegistrationsController
|
||||
end
|
||||
redirect_to "/"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sign_in_params
|
||||
params.require(:user).permit(:email,:password,:remember_me)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -3,6 +3,9 @@ class User < ApplicationRecord
|
||||
has_many :runs
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
|
||||
validates :email, presence: true, uniqueness: true
|
||||
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
|
||||
<%= render "shared/links" %>-->
|
||||
<div class="container">
|
||||
<p class="alert alert-container" align="center"><%= flash[:error] %> </p>
|
||||
<div class="row new_user_row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-primary">
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
class MakeUserEmailUniq < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :users, :email, :string, {unique: true, null: false , default: ""}
|
||||
end
|
||||
end
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170210202948) do
|
||||
ActiveRecord::Schema.define(version: 20170329193000) do
|
||||
|
||||
create_table "companies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "company_name"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user