KaiRo bug 392 - Create an interstitial page to confirm the user to log in
[authserver.git] / index.php
index 76e11d28fa6f47e4734fc1ebc2a5c74cab5a3b53..23a045d66bc716e8589252f8014171d59330390a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -17,7 +17,13 @@ $head->appendJSFile('authsystem.js');
 $title->appendText('KaiRo.at Authentication Server');
 $h1 = $body->appendElement('h1', 'KaiRo.at Authentication Server');
 
+// Make the document not be scaled on mobile devices.
+$vpmeta = $head->appendElement('meta');
+$vpmeta->setAttribute('name', 'viewport');
+$vpmeta->setAttribute('content', 'width=device-width, height=device-height');
+
 $errors = $utils->checkForSecureConnection();
+$utils->sendSecurityHeaders();
 
 $para = $body->appendElement('p', _('This login system does not work without JavaScript. Please activate JavaScript for this site to log in.'));
 $para->setAttribute('id', 'jswarning');
@@ -34,7 +40,7 @@ if (!count($errors)) {
     $result = $db->prepare('UPDATE `auth_sessions` SET `logged_in` = FALSE WHERE `id` = :sessid;');
     if (!$result->execute(array(':sessid' => $session['id']))) {
       $utils->log('logout_failure', 'session: '.$session['id']);
-      $errors[] = _('The email address is invalid.');
+      $errors[] = _('Unexpected error while logging out.');
     }
     $session['logged_in'] = 0;
   }
@@ -214,7 +220,7 @@ if (!count($errors)) {
       }
     }
     else {
-      $errors[] = _('The form you used was not valid. Possibly it has expired and you need to initiate the action again.');
+      $errors[] = _('The form you used was not valid. Possibly it has expired and you need to initiate the action again, or you have disabled cookies for this site.');
     }
   }
   elseif (array_key_exists('reset', $_GET)) {
@@ -360,11 +366,17 @@ if (!count($errors)) {
     $para->setAttribute('class', 'verifyinfo pending');
     $para = $body->appendElement('p', _('Reload this page after you confirm to continue.'));
     $para->setAttribute('class', 'verifyinfo pending');
+    $para = $body->appendElement('p');
+    $para->setAttribute('class', 'verifyinfo pending');
+    $link = $para->appendLink('./', _('Reload'));
   }
   elseif ($pagetype == 'resetmail_sent') {
     $para = $body->appendElement('p',
         _('An email has been sent to the requested account with further information. If you do not receive an email then please confirm you have entered the same email address used during account registration.'));
     $para->setAttribute('class', 'resetinfo pending');
+    $para = $body->appendElement('p');
+    $para->setAttribute('class', 'resetinfo pending small');
+    $link = $para->appendLink('./', _('Back to top'));
   }
   elseif ($pagetype == 'resetstart') {
     $para = $body->appendElement('p', _('If you forgot your password or didn\'t receive the registration confirmation, please enter your email here.'));
@@ -382,10 +394,13 @@ if (!count($errors)) {
     $litem = $ulist->appendElement('li');
     $litem->appendInputHidden('tcode', $utils->createTimeCode($session));
     $submit = $litem->appendInputSubmit(_('Send instructions to email'));
+    $para = $form->appendElement('p');
+    $para->setAttribute('class', 'toplink small');
+    $link = $para->appendLink('./', _('Cancel'));
   }
   elseif ($pagetype == 'resetpwd') {
     $para = $body->appendElement('p', sprintf(_('You can set a new password for %s here.'), $user['email']));
-    $para->setAttribute('class', '');
+    $para->setAttribute('class', 'newpwdinfo');
     $form = $body->appendForm('./', 'POST', 'newpwdform');
     $form->setAttribute('id', 'loginform');
     $form->setAttribute('class', 'loginarea hidden');
@@ -408,6 +423,9 @@ if (!count($errors)) {
       $litem->appendInputHidden('vcode', $user['verify_hash']);
     }
     $submit = $litem->appendInputSubmit(_('Save password'));
+    $para = $form->appendElement('p');
+    $para->setAttribute('class', 'toplink small');
+    $link = $para->appendLink('./', _('Cancel'));
   }
   elseif ($pagetype == 'clientlist') {
     $scopes = array('clientreg', 'email');
@@ -447,6 +465,9 @@ if (!count($errors)) {
     //$inptxt = $cell->appendInputText('scope', 100, 20, 'scope');
     $cell = $trow->appendElement('td');
     $submit = $cell->appendInputSubmit(_('Create'));
+    $para = $form->appendElement('p');
+    $para->setAttribute('class', 'toplink');
+    $link = $para->appendLink('./', _('Back to top'));
   }
   elseif ($session['logged_in']) {
     if ($pagetype == 'reset_done') {