You are here

ga_login.install in Google Authenticator login 6

Same filename and directory in other branches
  1. 8 ga_login.install
  2. 7 ga_login.install

Install, update and uninstall functions for the ga_login module.

File

ga_login.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the ga_login module.
 *
 */

/**
 * Implements hook_schema().
 */
function ga_login_schema() {
  $schema['ga_login'] = array(
    'description' => 'Table that contains ga specific data.',
    'fields' => array(
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'Unique user name + site name.',
      ),
      'keydata' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'Key data for GA.',
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function ga_login_install() {
  drupal_install_schema('ga_login');
  variable_set('ga_login_textname', variable_get('site_name', 'Drupal'));
}

/**
 * Implements hook_uninstall().
 */
function ga_login_uninstall() {
  drupal_uninstall_schema('ga_login');
  variable_del('ga_login_textname');
  variable_del('ga_login_textid');
  variable_del('ga_login_totp_skew');
  variable_del('ga_login_hotp_skew');
}

/**
 * Store the current site name as GA Login realm if the realm is not set, to
 * prevent future site name changes from invalidating existing GA accounts.
 */
function ga_login_update_6101() {

  // Only save the current site name if the ga_login_textname variable is
  // currently not set. If it is set to empty (''), leave it as is since
  // changing it to site name will invalidate existing accounts.
  if (variable_get('ga_login_textname', FALSE) === FALSE) {
    variable_set('ga_login_textname', variable_get('site_name', 'Drupal'));
  }
}

Functions

Namesort descending Description
ga_login_install Implements hook_install().
ga_login_schema Implements hook_schema().
ga_login_uninstall Implements hook_uninstall().
ga_login_update_6101 Store the current site name as GA Login realm if the realm is not set, to prevent future site name changes from invalidating existing GA accounts.