sms-pager/app/controllers/oauths_controller.rb
2015-10-20 21:49:59 -05:00

33 lines
785 B
Ruby

class OauthsController < ApplicationController
skip_before_action :require_login
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
msg = "Your account must be pre-approved. Please contact the administrator."
redirect_to root_path, notice: msg
end
end
private
# 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
def auth_params
params.permit(:code, :provider)
end
end