class AuthController < ActionController::Base include ShopliftClient protect_from_forgery with: :exception def auth local_redirect_uri = if Rails.configuration.settings['verify_auth_with_current_url'] "#{root_url}auth/" else Rails.configuration.settings['authlift_redirect_uri'] end response = client.auth_code.get_token params[:code], redirect_uri: local_redirect_uri, scope: scope self.session_cookie = response.token previous_url = session[:previous_url] session.delete :previous_url redirect_to(previous_url || '/') end def destroy authenticate_user! return if current_user.blank? signouttoken = session_cookie session_cookie = nil redirect_to "#{Rails.configuration.settings['authlift_url']}users/sign_outx?signouttoken=#{signouttoken}", allow_other_host: true end def change_company authenticate_user! return if current_user.blank? new_company_code = params.except(:_method, :authenticity_token).permit(:new_company_code)[:new_company_code] signouttoken = session_cookie redirect_to "#{Rails.configuration.settings['authlift_url']}users/change_companyx/#{new_company_code}?change_company_token=#{signouttoken}", allow_other_host: true end def change_language authenticate_user! return if current_user.blank? new_language_code = params.except(:_method, :authenticity_token).permit(:new_language_code)[:new_language_code] signouttoken = session_cookie redirect_to "#{Rails.configuration.settings['authlift_url']}users/change_languagex/#{new_language_code}?change_language_token=#{signouttoken}&return_to=#{request.base_url}", allow_other_host: true end def change_password authenticate_user! return if current_user.blank? redirect_to "#{Rails.configuration.settings['authlift_url']}users/change_password", allow_other_host: true end end