1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/sessions_controller.rb
Matchu d97c32b5da Upgrade to Rails 5.2.8.1
Some important little upgrades but mostly straightforward!

Note that there's still a known issue where item searches crash, I was hoping that this was a bug in Rails 4.2 that would be fixed on upgading to 5, but nope, oh well!

Also uhh I just got a bit silly and didn't actually mean to go all the way to 5.2 in one go, I had meant to start at 5.0… but tbh the 5.1 and 5.2 changes seem small, and this seems to be working, so. Yeah ok let's roll!
2023-10-23 19:05:05 -07:00

38 lines
1,002 B
Ruby

class SessionsController < ApplicationController
rescue_from Openneo::Auth::Session::InvalidSignature, :with => :invalid_signature
rescue_from Openneo::Auth::Session::MissingParam, :with => :missing_param
before_action :initialize_session, :only => [new]
skip_before_action :verify_authenticity_token, :only => [:create]
def new
redirect_to Openneo::Auth.remote_auth_url(params, session)
end
def create
session = Openneo::Auth::Session.from_params(params)
session.save!
render :text => 'Success'
end
def destroy
sign_out(:user)
redirect_to (params[:return_to] || root_path)
end
protected
def initialize_session
session[:session_initialization_placeholder] = nil
end
def invalid_signature(exception)
render :text => "Signature did not match. Check secret.",
:status => :unprocessable_entity
end
def missing_param(exception)
render :text => exception.message, :status => :unprocessable_entity
end
end