authentication via google

This commit is contained in:
2015-10-19 22:05:28 -05:00
parent b407d40747
commit 0cefdaf15c
8 changed files with 32 additions and 16 deletions

View File

@ -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

View File

@ -1,4 +1,6 @@
class DocsController < ApplicationController
skip_before_filter :require_login
def index
@doc = {
name: "sms-pager",

View File

@ -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

View File

@ -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)

View File

@ -1 +1 @@
= yield
= yield