2015-10-07 22:03:31 -05:00
|
|
|
class OauthsController < ApplicationController
|
2015-10-20 21:49:59 -05:00
|
|
|
skip_before_action :require_login
|
2015-10-07 22:03:31 -05:00
|
|
|
|
|
|
|
def oauth
|
|
|
|
login_at(params[:provider])
|
|
|
|
end
|
|
|
|
|
|
|
|
def callback
|
|
|
|
provider = params[:provider]
|
|
|
|
@user = login_from(provider)
|
|
|
|
|
|
|
|
if @user
|
|
|
|
redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
|
|
|
else
|
2015-10-19 22:05:28 -05:00
|
|
|
msg = "Your account must be pre-approved. Please contact the administrator."
|
|
|
|
redirect_to root_path, notice: msg
|
2015-10-07 22:03:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-10-19 22:05:28 -05:00
|
|
|
# def create_and_login provider
|
|
|
|
# @user = create_from(provider)
|
|
|
|
# reset_session # protect from session fixation attack
|
|
|
|
# auto_login(@user)
|
|
|
|
# redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
|
|
|
# end
|
|
|
|
|
2015-10-07 22:03:31 -05:00
|
|
|
def auth_params
|
|
|
|
params.permit(:code, :provider)
|
|
|
|
end
|
|
|
|
end
|