Okechi Onyeje 86e1dace76 subdomain routing now working to route application to proper app.
- This will need to revamped later on to potentially have a rack app serving the different rails applications and static website.
2017-04-16 16:40:25 -04:00

32 lines
757 B
Ruby

class SessionsController < Devise::RegistrationsController
include ApplicationHelper
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
#Do we need this code below? It was never running before
#resource = warden.authenticate!(:scope => :user)
sign_in(@user)
if !current_user.admin
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
end
redirect_to "/"
end
private
def sign_in_params
params.require(:user).permit(:email,:password,:remember_me)
end
end