You are here

auto_login_url.install in Auto Login URL 8

Same filename and directory in other branches
  1. 7 auto_login_url.install
  2. 2.x auto_login_url.install

Install file.

File

auto_login_url.install
View source
<?php

/**
 * @file
 * Install file.
 */

/**
 * Implements hook_schema().
 */
function auto_login_url_schema() {
  $schema['auto_login_url'] = [
    'description' => 'Auto login records.',
    'fields' => [
      'id' => [
        'description' => 'ID of the record.',
        'type' => 'serial',
        'not null' => TRUE,
      ],
      'uid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Primary Key: {users}.uid for user.',
      ],
      'hash' => [
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
        'default' => '',
        'description' => 'Unique hash tag for the generated link.',
      ],
      'destination' => [
        'type' => 'varchar',
        'length' => 1000,
        'not null' => FALSE,
        'default' => '',
        'description' => 'The destination after user login.',
      ],
      'timestamp' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Timestamp of the creation of the auto login link.',
      ],
    ],
    'indexes' => [
      'hash_index' => [
        'hash',
      ],
      'timestamp_index' => [
        'timestamp',
      ],
    ],
    'primary key' => [
      'id',
    ],
    'foreign keys' => [
      'user' => [
        'table' => 'users',
        'columns' => [
          'uid' => 'uid',
        ],
      ],
    ],
  ];
  return $schema;
}

/**
 * [2016-04-06] Add token length variable.
 */
function auto_login_url_update_8001() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('auto_login_url.settings');
  $config
    ->set('token_length', 64);
  $config
    ->save(TRUE);
}

/**
 * [2017-04-03] Reset secret.
 */
function auto_login_url_update_8002() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('auto_login_url.settings');
  $config
    ->set('secret', '');
  $config
    ->save(TRUE);
}

Functions

Namesort descending Description
auto_login_url_schema Implements hook_schema().
auto_login_url_update_8001 [2016-04-06] Add token length variable.
auto_login_url_update_8002 [2017-04-03] Reset secret.