function mo_auth_save_customer in Google Authenticator / 2 Factor Authentication - 2FA 7
2 calls to mo_auth_save_customer()
- mo_auth_customer_setup_submit in ./
mo_auth_customer_setup.inc - Handle submit for customer setup.
- mo_auth_validate_otp_submit in ./
mo_auth_customer_setup.inc - Validate OTP.
File
- ./
mo_auth_customer_setup.inc, line 408 - Contains form for customer setup.
Code
function mo_auth_save_customer($user, $json, $username, $phone) {
variable_set('mo_auth_customer_id', $json->id);
variable_set('mo_auth_customer_token_key', $json->token);
variable_set('mo_auth_customer_admin_email', $username);
variable_set('mo_auth_customer_admin_phone', $phone);
variable_set('mo_auth_customer_api_key', $json->apiKey);
variable_set('mo_auth_customer_app_secret', $json->appSecret);
isset($json->appSecret) ? variable_set('mo_auth_customer_app_secret', $json->appSecret) : NULL;
$user->miniorange_registered_email[LANGUAGE_NONE][0]['value'] = $username;
$user->configured_auth_methods[LANGUAGE_NONE][0]['value'] = array(
AuthenticationType::$EMAIL_VERIFICATION['code'],
);
$current_status = 'PLUGIN_CONFIGURATION';
variable_set('mo_auth_status', $current_status);
user_save($user);
// Update the customer second factor to OOB Email in miniOrange
$customer = new MiniorangeCustomerProfile();
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $username, '', '', AuthenticationType::$EMAIL_VERIFICATION['code']);
$user_api_handler = new UsersAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$user_api_handler
->update($miniorange_user);
$license_response = $user_api_handler
->fetchLicense();
$license_type = 'DEMO';
$license_plan = 'DEMO';
$no_of_users = 1;
if ($license_response->status == 'SUCCESS') {
$license_type = $license_response->licenseType;
if ($license_type == 'DRUPAL_2FA_PLUGIN') {
$license_plan = $license_response->licensePlan;
}
$no_of_users = $license_response->noOfUsers;
}
variable_set('mo_auth_2fa_license_type', $license_type);
variable_set('mo_auth_2fa_license_plan', $license_plan);
variable_set('mo_auth_2fa_license_no_of_users', $no_of_users);
variable_set('mo_auth_2fa_sms_remaining', isset($license_response->smsRemaining) ? $license_response->smsRemaining : '');
variable_set('mo_auth_2fa_email_remaining', isset($license_response->emailRemaining) ? $license_response->emailRemaining : '');
variable_set('mo_auth_2fa_license_expiry', isset($license_response->licenseExpiry) ? date('Y-M-d H:i:s', strtotime($license_response->licenseExpiry)) : '');
variable_set('mo_auth_2fa_support_expiry', isset($license_response->supportExpiry) ? date('Y-M-d H:i:s', strtotime($license_response->supportExpiry)) : '');
variable_set('mo_auth_enable_two_factor', TRUE);
variable_set('mo_auth_enforce_inline_registration', FALSE);
}