Class: KirguduSso::AuthenticationsController
- Inherits:
-
BaseController
- Object
- KirguduBase::ApplicationController
- BaseController
- KirguduSso::AuthenticationsController
- Defined in:
- app/controllers/kirgudu_sso/authentications_controller.rb
Instance Method Summary collapse
- #delete_user ⇒ Object
- #delete_user_process ⇒ Object
- #login ⇒ Object
- #login_process ⇒ Object
- #logout ⇒ Object
- #register ⇒ Object
- #register_process ⇒ Object
- #restore_password ⇒ Object
- #restore_password_process ⇒ Object
Instance Method Details
#delete_user ⇒ Object
107 108 109 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 107 def delete_user end |
#delete_user_process ⇒ Object
111 112 113 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 111 def delete_user_process end |
#login ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 12 def login local_data = { messages: [], errors: [] } params_to_local_data = [:email, :password, :redirect_to] params_to_local_data.each do |param_name| local_data[param_name] = params[param_name] if params[param_name] end session[:redirect_to] = params[:redirect_to] if params[:redirect_to] render "/#{self.get_template_path}/authentications/login", locals: {data: local_data}, layout: "/#{self.get_template_path}/layouts/application" end |
#login_process ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 26 def login_process local_data = { messages: [], errors: [] } params_to_local_data = [:email, :password, :remember_me, :redirect_to] params_to_local_data.each do |param_name| local_data[param_name] = params[param_name] if params[param_name] end # Init Kirgudu Sso Client sso_client = ::KirguduSso::Client.new(@sso_application_id, @sso_application_secret_key) # Request Direct Login if verify_recaptcha begin sso_result = sso_client.user_login(params[:email], params[:password]) # Processing Login Result sso_result.symbolize_keys! ActiveRecord::Base.transaction do # logger.info "SSO USER RESULT: #{sso_result.to_json}" # logger.info "SSO UIN: #{sso_result[:uin]}" local_user = ::KirguduBase::Security::User.where(uin: sso_result[:uin]).first #logger.info "LOCAL USER NOT FOUND with UIN: #{sso_result[:uin]}" unless local_user unless local_user local_user = ::KirguduBase::Security::User.new local_user.mass_assign(sso_result) local_user.password = ::ChupakabraTools::Security.get_password_hash("") unless local_user.save local_user.errors.each do |value| local_data[:errors] << "#{value}: #{local_user.errors[value]}" end end end self.current_user_set_info(local_user, local_data[:remember_me]) if local_data[:errors].count == 0 # logger.info "CURRENT USER NAME: #{local_user.full_name}" # logger.info "CURRENT USER ID: #{local_user.id}" # logger.info "CURRENT USER UIN: #{local_user.uin}" # logger.info "CURRENT USER ERRORS: #{local_user.errors.to_json}" end rescue Exception => e local_data[:errors] << e. end else local_data[:errors] << I18n.t("kirgudu_sso.authentications.login.errors.captcha_error") end if @current_user redirect_to root_path else render "/#{self.get_template_path}/authentications/login", locals: {data: local_data}, layout: "/#{self.get_template_path}/layouts/application" end end |
#logout ⇒ Object
82 83 84 85 86 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 82 def logout self.clear_current_user_info #logger.info "session[:user_id]=: #{session[:user_id]}" redirect_to root_path end |
#register ⇒ Object
88 89 90 91 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 88 def register local_data = {} render "/#{self.get_template_path}/authentications/register", locals: {data: local_data} end |
#register_process ⇒ Object
93 94 95 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 93 def register_process end |
#restore_password ⇒ Object
97 98 99 100 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 97 def restore_password local_data = {} render "/#{self.get_template_path}/authentications/restore_password", locals: {data: local_data} end |
#restore_password_process ⇒ Object
102 103 104 |
# File 'app/controllers/kirgudu_sso/authentications_controller.rb', line 102 def restore_password_process end |