2010-10-18 14:58:45 -07:00
|
|
|
class SessionsController < ApplicationController
|
|
|
|
rescue_from Openneo::Auth::Session::InvalidSignature, :with => :invalid_signature
|
|
|
|
rescue_from Openneo::Auth::Session::MissingParam, :with => :missing_param
|
|
|
|
|
2023-08-02 16:05:02 -07:00
|
|
|
before_action :initialize_session, :only => [new]
|
2010-11-05 13:32:00 -07:00
|
|
|
|
2023-08-02 16:05:02 -07:00
|
|
|
skip_before_action :verify_authenticity_token, :only => [:create]
|
2010-10-18 14:58:45 -07:00
|
|
|
|
|
|
|
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
|
2011-01-26 10:40:15 -08:00
|
|
|
sign_out(:user)
|
2010-11-10 13:59:54 -08:00
|
|
|
redirect_to (params[:return_to] || root_path)
|
2010-10-18 14:58:45 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2010-11-05 13:32:00 -07:00
|
|
|
def initialize_session
|
|
|
|
session[:session_initialization_placeholder] = nil
|
|
|
|
end
|
|
|
|
|
2010-10-18 14:58:45 -07:00
|
|
|
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
|