Sha256: c8e1245aebf7903299d38b4fb0bec26e65fdab28e3b6d8e37a577d1fbdcfb818

Contents?: true

Size: 1.92 KB

Versions: 11

Compression:

Stored size: 1.92 KB

Contents

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}"
  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}"
  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}"
  end

  def change_password
    authenticate_user!
    return if current_user.blank?
    redirect_to "#{Rails.configuration.settings['authlift_url']}users/change_password"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopapp-0.3.76 app/controllers/auth_controller.rb
shopapp-0.2.75 app/controllers/auth_controller.rb
shopapp-0.2.74 app/controllers/auth_controller.rb
shopapp-0.2.73 app/controllers/auth_controller.rb
shopapp-0.2.72 app/controllers/auth_controller.rb
shopapp-0.2.71 app/controllers/auth_controller.rb
shopapp-0.2.70 app/controllers/auth_controller.rb
shopapp-0.2.69 app/controllers/auth_controller.rb
shopapp-0.2.68 app/controllers/auth_controller.rb
shopapp-0.2.67 app/controllers/auth_controller.rb
shopapp-0.2.66 app/controllers/auth_controller.rb