You are here

social_auth.install in Social Auth 8

Same filename and directory in other branches
  1. 8.2 social_auth.install
  2. 3.x social_auth.install

Install, update and uninstall functions for Social Auth.

File

social_auth.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for Social Auth.
 */

/**
 * Implements hook_update_N().
 */
function social_auth_update_8001(&$sandbox) {
  $config = \Drupal::service('config.factory')
    ->getEditable('social_auth.settings');

  // Set and save new message value.
  $config
    ->set('post_login_path', 'user')
    ->set('redirect_user_form', FALSE)
    ->set('disable_admin_login', TRUE)
    ->set('disabled_roles', array())
    ->save();
}

/**
 * Implements hook_update_N().
 *
 * PathValidator requires path to begin with '/', '?', or '#'.
 *
 * This update makes sure that if the post login value was "user" (the previous
 * default value), it is changed to "/user". This also changes the configuration
 * key post_login_path to post_login.
 */
function social_auth_update_8002(&$sandbox) {
  $config = \Drupal::configFactory()
    ->getEditable('social_auth.settings');
  $post_login = $config
    ->get('post_login_path');
  if ($post_login == 'user') {
    $config
      ->set('post_login', '/user');
  }
  else {
    $config
      ->set('post_login', $post_login);
  }
  $config
    ->save();
}

Functions