You are here

function mo_auth_create_form in Google Authenticator / 2 Factor Authentication - 2FA 7

Same name in this branch
  1. 7 configure_qrcode_authentication.inc \mo_auth_create_form()
  2. 7 configure_kba.inc \mo_auth_create_form()
  3. 7 configure_google_authenticator.inc \mo_auth_create_form()
  4. 7 test_kba_authentication.inc \mo_auth_create_form()
4 calls to mo_auth_create_form()
mo_auth_configure_google_authenticator in ./configure_google_authenticator.inc
mo_auth_configure_kba in ./configure_kba.inc
mo_auth_configure_qrcode_authentication in ./configure_qrcode_authentication.inc
mo_auth_test_kba_authentication in ./test_kba_authentication.inc
Menu callback for email verification.

File

./configure_google_authenticator.inc, line 134

Code

function mo_auth_create_form($base_url, $qrCode, $secret, $appName) {
  $androidAppLink = file_create_url($base_url . '/' . drupal_get_path('module', 'mo_auth') . '/includes/images/android-google-authenticator-app-link.png');
  $iPhoneAppLink = file_create_url($base_url . '/' . drupal_get_path('module', 'mo_auth') . '/includes/images/iphone-google-authenticator-app-link.png');
  $androidAppQR = file_create_url($base_url . '/' . drupal_get_path('module', 'mo_auth') . '/includes/images/android-google-authenticator-app-qr.jpg');
  $iPhoneAppQR = file_create_url($base_url . '/' . drupal_get_path('module', 'mo_auth') . '/includes/images/iphone-google-authenticator-app-qr.jpg');
  $step1 = '<div>
        <div class="mo2f_googleauth-steps"><b>Step 1:</b> Download & Install the ' . $appName . ' Authenticator app.</div>
        <div style="margin-bottom:20px;">
        <div style="width:50%;float:left;min-width:450px;">
          <div class="mo2f_googleauth-download-manual">
            <div class="mo2f_googleauth-download-header">Manual Installation</div>
            <div>
              <div style="font-size:1.1em;padding:10px;">iPhone Users</div>
              <div>
              <div style="width:60%;float:left">
                <ul>
                  <li>Go to App Store.</li>
                  <li>Search for ' . $appName . ' Authenticator.</li>
                  <li>Download and install the App.</li>
                </ul>
              </div>
              <div style="width:40%;float:left;">
                <a target="_blank" href="https://itunes.apple.com/in/app/google-authenticator/id388497605?mt=8"><img src="' . $iPhoneAppLink . '"></a>
              </div>
              </div>
              <br><br><br><br>
              <div style="font-size:1.1em;padding:10px;">Android Users</div>
              <div>
              <div style="width:60%;float:left;">
                <ul>
                  <li>Go to Google Play Store.</li>
                  <li>Search for ' . $appName . ' Authenticator.</li>
                  <li>Download and install the App.</li>
                </ul>
              </div>
              <div style="width:40%;float:left;">
                <a target="_blank" href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2"><img src="' . $androidAppLink . '"></a>
              </div>
              </div>
            </div>
          </div>
        </div>
        <div style="width:50%;float:left;' . ($appName != "Google" ? 'visibility: hidden;' : '') . 'min-width:450px;">
          <div class="mo2f_googleauth-download-qrcode">
            <div class="mo2f_googleauth-download-header">Scan QR Code</div>
            <div style="text-align:center;padding:25px;">
            <div style="width:50%;float:left">
              <div>
                <img src="' . $iPhoneAppQR . '">
              </div>
              <span>Apple App Store<br />(iOS)</span>
            </div>
            <div style="width:50%;float:left">
              <div>
                <img src="' . $androidAppQR . '">
              </div>
              <span>Google Play Store<br />(Android)</span>
            </div>
            </div>
          </div>
        </div>
        </div>
        </div>';
  $secret = MoAuthUtilities::indentSecret($secret);
  $step2 = '<div style="width: 100%;float:left;padding-top: 10px;">
        <div class="mo2f_googleauth-steps"><b>Step 2:</b> Scan the below QR Code from ' . $appName . ' Authenticator app.</div>
        <div style="text-align:center">
        <div style="display:inline-block;width:33%">
          <img src="data:image/jpg;base64,' . $qrCode . '">
        </div>
        <div style="vertical-align: top;display: inline-flex;padding: 75px 0px;">
          <p style="margin: auto 10px;font-size:12pt;font-weight:bold">OR</p>
        </div>
        <div style="display:inline-block;width:33%">
          <div class="mo2f_googleauth-secret">
          <span style="padding:10px;">
            <p style="font-size: 10pt;">Use the following secret and Choose time-based.</p><p>
            </p><p id="googleAuthSecret" style="font-size: 13pt; font-weight: bold">' . $secret . '</p>
            <p style="font-size: 9pt;">(Spaces don&#39;t matter)</p><p>

        </p></span></div>
        </div>
        </div>
        </div>';
  $step3 = '<div style="width: 100%;float:left;padding-top: 10px;">
        <div class="mo2f_googleauth-steps"><b>Step 3:</b> Enter the Passcode generated by ' . $appName . ' Authenticator app.</div>
        </div>';
  return $step1 . $step2 . $step3;
}