Merge branch 'master' into setup/pagination
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
helper_method :current_user, :logged_in?
|
||||
include Pagy::Backend
|
||||
|
||||
def require_login
|
||||
redirect_to login_url unless current_user.present?
|
||||
redirect_to login_url if current_user.blank?
|
||||
end
|
||||
|
||||
def current_user
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FileUploadsController < ApplicationController
|
||||
def show
|
||||
@form = Form.find_by!(token: params[:form_id])
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'google/apis/sheets_v4'
|
||||
require 'google/api_client/client_secrets'
|
||||
class FormsController < ApplicationController
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class HomeController < ApplicationController
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
redirect_to forms_url if logged_in?
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class OauthsController < ApplicationController
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OauthsController < ApplicationController
|
||||
# Sends the user on a trip to the provider,
|
||||
# and after authorizing there back to the callback url.
|
||||
def oauth
|
||||
@@ -9,26 +10,25 @@ class OauthsController < ApplicationController
|
||||
def callback
|
||||
provider = params[:provider]
|
||||
if @user = login_from(provider)
|
||||
redirect_to root_path, :notice => "Logged in from #{provider.titleize}!"
|
||||
redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
||||
else
|
||||
begin
|
||||
@user = create_from(provider)
|
||||
if authentication = @user.authentications.find_by(provider: provider)
|
||||
authentication.update({
|
||||
access_token: @access_token.token,
|
||||
refresh_token: @access_token.refresh_token,
|
||||
expires_at: Time.at(@access_token.expires_at)
|
||||
})
|
||||
access_token: @access_token.token,
|
||||
refresh_token: @access_token.refresh_token,
|
||||
expires_at: Time.zone.at(@access_token.expires_at)
|
||||
})
|
||||
end
|
||||
|
||||
reset_session
|
||||
auto_login(@user)
|
||||
redirect_to root_path, :notice => "Logged in from #{provider.titleize}!"
|
||||
rescue
|
||||
redirect_to root_path, notice: "Logged in from #{provider.titleize}!"
|
||||
rescue StandardError
|
||||
Rails.logger.error("Failed to login from #{provider}")
|
||||
redirect_to root_path, :alert => "Failed to login from #{provider.titleize}!"
|
||||
redirect_to root_path, alert: "Failed to login from #{provider.titleize}!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class SessionsController < ApplicationController
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SessionsController < ApplicationController
|
||||
def new
|
||||
reset_session
|
||||
end
|
||||
@@ -8,5 +9,4 @@ class SessionsController < ApplicationController
|
||||
reset_session
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'google/apis/sheets_v4'
|
||||
class SubmissionsController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token
|
||||
@@ -14,10 +16,14 @@ class SubmissionsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @submission.save
|
||||
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
||||
format.html do
|
||||
redirect_to(@form.thank_you_url) if @form.thank_you_url.present?
|
||||
end
|
||||
format.json { render(json: { success: true, submission: @submission.data }) }
|
||||
else
|
||||
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
||||
format.html do
|
||||
redirect_to(@form.thank_you_url) if @form.thank_you_url.present?
|
||||
end
|
||||
format.json { render(json: { error: @submission.errors }, status: 422) }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user