-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_encrypt.install
More file actions
47 lines (42 loc) · 1.63 KB
/
password_encrypt.install
File metadata and controls
47 lines (42 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @file
* This file handles all the install & uninstall features.
*/
/**
* Implements hook_requirements().
*/
function password_encrypt_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$requirements['password_encrypt']['title'] = t('Password Encrypt requirements');
if (password_encrypt_library_check() && function_exists('openssl_decrypt')) {
$requirements['password_encrypt']['value'] = t('Installed');
$requirements['password_encrypt']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['password_encrypt']['value'] = t('OpenSSL/CryptoJS library is not installed');
$requirements['password_encrypt']['severity'] = REQUIREMENT_ERROR;
$requirements['password_encrypt']['description'] = t('Either OpenSSL extension or CryptoJS library is not installed. Please check.<br>Please download <a href="@crypto" target="_blank">CryptoJS library</a> to function correctly.<br>Unzip CryptoJS library and copy rollups/aes.js to libraries/CryptoJS.', [
'@crypto' => 'https://code.google.com/archive/p/crypto-js/downloads',
]);
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
function password_encrypt_install() {
Drupal::state()->set('password_encrypt.passkey', bin2hex(openssl_random_pseudo_bytes(8)));
if (!password_encrypt_library_check()) {
\Drupal::messenger()->addError(
t('CryptoJS library is missing. Please check readme.txt or go to help for installation of CryptoJS library.'));
}
}
/**
* Implements hook_uninstall().
*/
function password_encrypt_uninstall() {
Drupal::state()->delete('password_encrypt.passkey');
}