Skip to content

Commit

Permalink
Removed "lr_ciam_preprocess" hook from lr_ciam module.
Browse files Browse the repository at this point in the history
  • Loading branch information
SUDHANSHU authored and SUDHANSHU committed May 29, 2018
1 parent 3c22f3f commit a2dac45
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 43 deletions.
Binary file modified drupal-8/package/customer_identity_and_access_management.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ further information.

-- CHANGE LOG --

-- 8.x-3.8 --
* Added cache contexts of user roles in SSO module to improve performance.
-- 8.x-3.9 --
* Removed "lr_ciam_preprocess" hook from lr_ciam module.

-- 8.x-3.8 --
* Added cache contexts of user roles in SSO module to improve performance.
* Added loading image variable to the required pages.
* Added functionality to logout user from drupal after lr access token expired.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ type: module
description: 'Allow users to sign up through a registration form. User Registration offers fully customized options for collecting and updating user data.'
package: CIAM LoginRadius
configure: lr_ciam.settings_form
version: '8.x-3.8'
version: '8.x-3.9'
core: '8.x'
project: 'customer_identity_and_access_management'
Original file line number Diff line number Diff line change
Expand Up @@ -791,41 +791,6 @@ function lr_ciam_user_update($account) {
}
}

/**
* Implements hook_preprocess().
*
* @param $variables
*
*/
function lr_ciam_preprocess(&$variables) {
$config = \Drupal::config('lr_ciam.settings');
$user = \Drupal::currentUser()->getRoles();
if (!in_array("administrator", $user) && !\Drupal::currentUser()
->isAnonymous()) {
$apiKey = trim($config->get('api_key'));
$apiSecret = trim($config->get('api_secret'));
$socialObject = new SocialLoginAPI($apiKey, $apiSecret, array('output_format' => 'json'));
try {
$result = $socialObject->tokenValidate(trim($_SESSION['_sf2_attributes']['access_token']));
if(isset($result->errorCode) && $result->errorCode == '906'){
$domain = Url::fromRoute('<front>')->setAbsolute()->toString();
$redirectUrl = $domain.'user/logout';
$response = new TrustedRedirectResponse($redirectUrl);
\Drupal::logger('ciam')->error($e);
return $response->send();
}
}

catch (LoginRadiusException $e) {
$domain = Url::fromRoute('<front>')->setAbsolute()->toString();
$redirectUrl = $domain.'user/logout';
$response = new TrustedRedirectResponse($redirectUrl);
\Drupal::logger('ciam')->error($e);
return $response->send();
}
}
}

/**
* User form alter.
*
Expand All @@ -837,8 +802,7 @@ function lr_ciam_form_user_form_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::config('lr_ciam.settings');
$user = \Drupal::currentUser()->getRoles();

if (!in_array("administrator", $user) && !\Drupal::currentUser()
->isAnonymous()) {
if (!in_array("administrator", $user) && !\Drupal::currentUser()->isAnonymous()) {
unset($form['#validate'][1]);
unset($form['account']['pass']);
unset($form['account']['current_pass']);
Expand All @@ -848,6 +812,24 @@ function lr_ciam_form_user_form_alter(&$form, FormStateInterface $form_state) {
$userObject = new UserAPI($apiKey, $apiSecret, array('output_format' => 'json'));
$socialObject = new SocialLoginAPI($apiKey, $apiSecret, array('output_format' => 'json'));

try {
$result = $socialObject->tokenValidate(trim($_SESSION['_sf2_attributes']['access_token']));
if(isset($result->errorCode) && $result->errorCode == '906'){
$domain = Url::fromRoute('<front>')->setAbsolute()->toString();
$redirectUrl = $domain.'user/logout';
$response = new TrustedRedirectResponse($redirectUrl);
\Drupal::logger('ciam')->error($result->description);
return $response->send();
}
}
catch (LoginRadiusException $e) {
$domain = Url::fromRoute('<front>')->setAbsolute()->toString();
$redirectUrl = $domain.'user/logout';
$response = new TrustedRedirectResponse($redirectUrl);
\Drupal::logger('ciam')->error($e);
return $response->send();
}

$userprofile = $_SESSION['_sf2_attributes']['user_profile_data'];
$defaultEmail = isset($userprofile->Email) ? $userprofile->Email[0]->Value : '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package: CIAM LoginRadius
dependencies:
- lr_ciam
configure: lr_hostedpage.settings_form
version: '8.x-3.8'
version: '8.x-3.9'
core: '8.x'
project: 'customer_identity_and_access_management'
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package: CIAM LoginRadius
dependencies:
- drupal:lr_ciam
- drupal:simple_oauth
version: '8.x-3.8'
version: '8.x-3.9'
core: '8.x'
project: 'customer_identity_and_access_management'
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package: CIAM LoginRadius
dependencies:
- lr_ciam
configure: lr_sso.settings_form
version: '8.x-3.8'
version: '8.x-3.9'
core: '8.x'
project: 'customer_identity_and_access_management'

0 comments on commit a2dac45

Please sign in to comment.