Class: AuthController

Inherits:
ActionController::Base
  • Object
show all
Includes:
ShopliftClient
Defined in:
app/controllers/auth_controller.rb

Instance Method Summary collapse

Methods included from ShopliftClient

#authenticate_company!, #authenticate_user, #authenticate_user!, #authenticate_user_or_api!, #client, #company_info, #company_logo_path_defined, #current_auditor, #current_company, #current_user, #current_user_json, #find_company_by_code, #get, #handle_not_authorized, #hide_search_for_this_action, #home_link_path, #local_authlift_redirect_uri, #post, #redirect_unauthorized, #scope, #search_remote, #session_cookie, #session_cookie=, #shoplift_login_url, #show_search_for_this_action, #srv, #supported_locales_defined, #user_signed_in?

Methods included from Shopapp3

#sidebar_actions_list

Instance Method Details

#authObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/auth_controller.rb', line 5

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

#change_companyObject



30
31
32
33
34
35
36
37
# File 'app/controllers/auth_controller.rb', line 30

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

#change_languageObject



39
40
41
42
43
44
45
46
# File 'app/controllers/auth_controller.rb', line 39

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

#change_passwordObject



48
49
50
51
52
# File 'app/controllers/auth_controller.rb', line 48

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

#destroyObject



21
22
23
24
25
26
27
28
# File 'app/controllers/auth_controller.rb', line 21

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