forked from MarinaBaySaaS/tripAgvisor
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from tamu-edu-students/testing
Testing
- Loading branch information
Showing
24 changed files
with
802 additions
and
429 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class SessionsController < ApplicationController | ||
def create | ||
user_info = request.env['omniauth.auth'] | ||
|
||
# Allow non tamu emails for testing | ||
if params[:hd] != 'tamu.edu' && 1.zero? | ||
flash[:alert] = 'Must login with @tamu.edu email address!' | ||
redirect_to root_path and return | ||
end | ||
|
||
dbUser = User.find_by email: user_info['info']['email'] | ||
if dbUser.nil? | ||
dbUser = User.create(uid: user_info['uid'], name: user_info['info']['name'], | ||
email: user_info['info']['email']) | ||
elsif dbUser.banned | ||
flash[:alert] = 'Your account has been banned! Please contact the administrators.' | ||
redirect_to root_path and return | ||
end | ||
|
||
# if email address matches the one in the /config/application.rb file then make that user an admin | ||
if user_info['info']['email'] == Rails.configuration.admin_email | ||
dbUser.admin = true | ||
dbUser.save | ||
end | ||
|
||
session[:user] = dbUser.id | ||
session[:user_admin] = dbUser.admin | ||
session[:user_img] = user_info['info']['image'] | ||
session[:user_program_id] = dbUser.program_id | ||
session[:user_email] = dbUser.email | ||
|
||
redirect_to(root_path) and return | ||
end | ||
|
||
def destroy | ||
session.delete :user | ||
session.delete :user_admin | ||
session.delete :user_img | ||
session.delete :user_program_id | ||
session.delete :user_email | ||
redirect_to root_path | ||
end | ||
end | ||
# frozen_string_literal: true | ||
|
||
class SessionsController < ApplicationController | ||
def create | ||
user_info = request.env['omniauth.auth'] | ||
|
||
# Allow non tamu emails for testing | ||
if params[:hd] != 'tamu.edu' && 1.zero? | ||
flash[:alert] = 'Must login with @tamu.edu email address!' | ||
redirect_to root_path and return | ||
end | ||
|
||
dbUser = User.find_by email: user_info['info']['email'] | ||
if dbUser.nil? | ||
dbUser = User.create(uid: user_info['uid'], name: user_info['info']['name'], | ||
email: user_info['info']['email']) | ||
elsif dbUser.banned | ||
flash[:alert] = 'Your account has been banned! Please contact the administrators.' | ||
redirect_to root_path and return | ||
end | ||
|
||
# if email address matches the one in the /config/application.rb file then make that user an admin | ||
if user_info['info']['email'] == Rails.configuration.admin_email | ||
dbUser.admin = true | ||
dbUser.save | ||
end | ||
|
||
session[:user] = dbUser.id | ||
session[:user_admin] = dbUser.admin | ||
session[:user_img] = user_info['info']['image'] | ||
session[:user_program_id] = dbUser.program_id | ||
session[:user_email] = dbUser.email | ||
|
||
redirect_to(root_path) and return | ||
end | ||
|
||
def destroy | ||
session.delete :user | ||
session.delete :user_admin | ||
session.delete :user_img | ||
session.delete :user_program_id | ||
session.delete :user_email | ||
redirect_to root_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.