authentication via google
This commit is contained in:
@ -2,6 +2,12 @@ class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
before_filter :require_login
|
||||
respond_to :html, :json
|
||||
|
||||
private
|
||||
|
||||
def not_authenticated
|
||||
redirect_to :root, alert: "Please login first."
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
class DocsController < ApplicationController
|
||||
skip_before_filter :require_login
|
||||
|
||||
def index
|
||||
@doc = {
|
||||
name: "sms-pager",
|
||||
|
@ -12,19 +12,20 @@ class OauthsController < ApplicationController
|
||||
if @user
|
||||
redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
||||
else
|
||||
begin
|
||||
@user = create_from(provider)
|
||||
reset_session # protect from session fixation attack
|
||||
auto_login(@user)
|
||||
redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
||||
rescue
|
||||
redirect_to root_path, alert: "Failed to login from #{provider.titleize}!"
|
||||
end
|
||||
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
|
||||
|
@ -1,4 +1,5 @@
|
||||
%p= link_to 'Login with Google', auth_at_provider_path(provider: :google)
|
||||
|
||||
%h2 Something more helpful later
|
||||
%p= raw(ap @doc)
|
||||
-#
|
||||
%h2 Something more helpful later
|
||||
%p= raw(ap @doc)
|
||||
|
@ -1 +1 @@
|
||||
= yield
|
||||
= yield
|
||||
|
Reference in New Issue
Block a user