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
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def authenticate_user
|
def authenticate_user
|
||||||
if session[:user_id]
|
if session[:user_id]
|
||||||
# set current user object to @current_user object variable
|
# set current user object to @current_user object variable
|
||||||
@ -11,6 +12,7 @@ class ApplicationController < ActionController::Base
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_login_state
|
def save_login_state
|
||||||
if session[:user_id]
|
if session[:user_id]
|
||||||
redirect_to(:controller => 'sessions', :action => 'home')
|
redirect_to(:controller => 'sessions', :action => 'home')
|
||||||
@ -19,4 +21,5 @@ class ApplicationController < ActionController::Base
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,19 +1,22 @@
|
|||||||
class RegistrationsController < Devise::RegistrationsController
|
class RegistrationsController < Devise::RegistrationsController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
#protected
|
#protected
|
||||||
def new
|
def new
|
||||||
Apartment::Tenant.switch!
|
Apartment::Tenant.switch!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#Method to create a new User
|
||||||
def create
|
def create
|
||||||
@user = User.new(sign_up_params)
|
user_params = sign_up_params
|
||||||
if params[:password] == nil || params[:password_confirmation] == nil
|
@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"
|
flash[:error] = "Need a password to sign up"
|
||||||
redirect_to '/signin'
|
redirect_to '/signin'
|
||||||
|
return
|
||||||
end
|
end
|
||||||
if params[:company_serial]
|
if params[:company_serial]
|
||||||
params.require(:user).permit(:company_id)
|
|
||||||
company = Company.find_by(company_token: params[:company_serial])
|
company = Company.find_by(company_token: params[:company_serial])
|
||||||
if company
|
if company
|
||||||
@user.company_id = company.id
|
@user.company_id = company.id
|
||||||
@ -21,18 +24,38 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
@user.admin = true
|
@user.admin = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
flash[:alert] = "The serial key provided was invalid."
|
||||||
|
redirect_to '/'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
flash[:alert] = "A company serial key must be provided to register."
|
||||||
|
redirect_to '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @user == ""
|
||||||
|
flash[:alert] = "Please provide a password to register with."
|
||||||
|
redirect_to '/'
|
||||||
|
else
|
||||||
@user.save
|
@user.save
|
||||||
|
begin
|
||||||
sign_in @user
|
sign_in @user
|
||||||
|
rescue
|
||||||
|
flash[:error] = "Email already in use"
|
||||||
|
redirect_to '/signin' and return
|
||||||
|
end
|
||||||
if !@user.admin
|
if !@user.admin
|
||||||
Apartment::Tenant.switch(Company.find(@user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
Apartment::Tenant.switch(Company.find(@user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
end
|
end
|
||||||
redirect_to "/"
|
redirect_to "/" and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
#Param checking method for creation of a new user
|
||||||
def sign_up_params
|
def sign_up_params
|
||||||
params.require(:user).permit(:email, :password, :password_confirmation)
|
params.require(:user).permit(:email, :password, :password_confirmation)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,20 @@
|
|||||||
class SessionsController < Devise::RegistrationsController
|
class SessionsController < Devise::RegistrationsController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
#def new
|
|
||||||
# Apartment::Tenant.switch!
|
def new
|
||||||
#end
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
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)
|
resource = warden.authenticate!(:scope => :user)
|
||||||
sign_in(:user, resource)
|
sign_in(:user, resource)
|
||||||
if !current_user.admin
|
if !current_user.admin
|
||||||
@ -12,4 +22,11 @@ class SessionsController < Devise::RegistrationsController
|
|||||||
end
|
end
|
||||||
redirect_to "/"
|
redirect_to "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def sign_in_params
|
||||||
|
params.require(:user).permit(:email,:password,:remember_me)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,6 +3,9 @@ class User < ApplicationRecord
|
|||||||
has_many :runs
|
has_many :runs
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
|
|
||||||
|
validates :email, presence: true, uniqueness: true
|
||||||
|
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
<%= render "shared/links" %>-->
|
<%= render "shared/links" %>-->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<p class="alert alert-container" align="center"><%= flash[:error] %> </p>
|
||||||
<div class="row new_user_row">
|
<div class="row new_user_row">
|
||||||
<div class="col-md-8 col-md-offset-2">
|
<div class="col-md-8 col-md-offset-2">
|
||||||
<div class="panel panel-primary">
|
<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.
|
# 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|
|
create_table "companies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||||
t.string "company_name"
|
t.string "company_name"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user