diff --git a/dictionaries/login.php b/dictionaries/login.php index 8696635c116cb3ede2c267ba73c3a6f895cc65e8..36e1d082a58c11a0bde5a6ae481ccf56b1e16b5c 100644 --- a/dictionaries/login.php +++ b/dictionaries/login.php @@ -4,8 +4,8 @@ $lang = array( 'error_header' => array( - 'en' => 'What you entered was not accepted!', - 'no' => 'Feil under innlogging', + 'en' => 'Error', + 'no' => 'Error', ), 'user_pass_header' => array( 'en' => 'Enter your username and password', @@ -38,5 +38,15 @@ $lang = array( 'no' => 'Synd! - Uten riktig brukernavn og passord kan du ikke autentisere deg. Det kan være noen som kan hjelpe deg. Forsøk å kontakt help-desk hos din hjemmeorganisasjon.', ), + 'error_nopassword' => array( + 'en' => 'You sent something to the login page, but for some reason the password was not sent. Try again please.', + 'no' => 'Du kontaktet loginsiden, men passordet ble ikke sendt med. Forsøk igjen.', + ), + + 'error_wrongpassword' => array( + 'en' => 'Wrong username or password.', + 'no' => 'Feil brukernavn eller passord.', + ), + ); \ No newline at end of file diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index fe70ff62aff6c536f978c73d829dfe0beeffde23..2a0596f6380764be3e795cc394a0bef34db0afd6 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -53,7 +53,10 @@ class SimpleSAML_XHTML_Template { // Language is not set, and we get the default language from the configuration. } else { - return $this->getDefaultLanguage('language.default'); + + #$nego = http_negotiate_language($this->configuration->getValue('language.available')); + + return $this->getDefaultLanguage(); } return $this->language; @@ -104,25 +107,8 @@ class SimpleSAML_XHTML_Template { include($filename); } - private function includeAtLanguageBase($file) { - + private function includeAtLanguageBase($file) { throw new Exception('Deprecated method call includeAtLanguageBase()'); - /* - $data = $this->data; - $filebase = $this->configuration->getPathValue('templatedir') . $this->getLanguage() . '/' ; - - if (!file_exists($filebase . $file)) { - $filebase = $this->configuration->getPathValue('templatedir') . - $this->configuration->getValue('language.default') . '/'; - - - if (!file_exists($filebase . $file) ) { - SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']'); - return; - } - } - include($filebase . $file); - */ } @@ -142,9 +128,6 @@ class SimpleSAML_XHTML_Template { return $this->t_not_translated($tag, $fallbacktag); } -# echo 'LANGTEXT: '; -# print_r($this->langtext); - $selected_language = $this->getLanguage(); $default_language = $this->getDefaultLanguage(); @@ -217,8 +200,6 @@ class SimpleSAML_XHTML_Template { */ public function show() { - - $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.use') . '/' . $this->template; diff --git a/templates/default/login.php b/templates/default/login.php index b67313bc35f1e28107872f311a226dc02ab0e924..6dc9a8c3881d139fdcea5a1c562a7896ab6f2834 100644 --- a/templates/default/login.php +++ b/templates/default/login.php @@ -2,51 +2,56 @@ if (!array_key_exists('icon', $this->data)) $this->data['icon'] = 'lock.png'; $this->includeAtTemplateBase('includes/header.php'); ?> + <script type="text/javascript"> + function focusit() { + document.getElementById('username').focus(); + } + window.onload = focusit; + </script> +<div id="content"> - <div id="content"> - - <?php if (isset($this->data['error'])) { ?> - <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5" - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/bomb.png" style="float: left; margin: 15px " /> - <h2><?php echo $this->t('error_header'); ?></h2> - - <p><?php echo htmlspecialchars($this->data['error']); ?> </p> - </div> - <?php } ?> - - <h2 style="break: both"><?php echo $this->t('user_pass_header'); ?></h2> - - <p><?php echo $this->t('user_pass_text'); ?></p> - - <form action="?" method="post" name="f"> + <?php if (isset($this->data['error'])) { ?> + <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/bomb.png" style="float: left; margin: 15px " /> + <h2><?php echo $this->t('error_header'); ?></h2> + + <p><?php echo $this->t($this->data['error']); ?> </p> + </div> + <?php } ?> - <table> - <tr> - <td rowspan="2"><img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/pencil.png" /></td> - <td style="padding: .3em;"><?php echo $this->t('username'); ?></td> - <td><input type="text" tabindex="1" name="username" - <?php if (isset($this->data['username'])) { - echo 'value="' . htmlspecialchars($this->data['username']) . '"'; - } ?> /></td> - <td style="padding: .4em;" rowspan="2"> - <input type="submit" tabindex="3" value="<?php echo $this->t('login_button'); ?>" /> - <input type="hidden" name="RelayState" value="<?php echo htmlspecialchars($this->data['relaystate']); ?>" /> - </td> - </tr> - <tr> - <td style="padding: .3em;"><?php echo $this->t('password'); ?></td> - <td><input type="password" tabindex="2" name="password" /></td> - </tr> - </table> - - - </form> - - - <h2><?php echo $this->t('help_header'); ?></h2> - - - <p><?php echo $this->t('help_text'); ?></p> + <h2 style="break: both"><?php echo $this->t('user_pass_header'); ?></h2> + + <p><?php echo $this->t('user_pass_text'); ?></p> + + <form action="?" method="post" name="f"> + + <table> + <tr> + <td rowspan="2"><img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/pencil.png" /></td> + <td style="padding: .3em;"><?php echo $this->t('username'); ?></td> + <td><input type="text" id="username" tabindex="1" name="username" + <?php if (isset($this->data['username'])) { + echo 'value="' . htmlspecialchars($this->data['username']) . '"'; + } ?> /></td> + <td style="padding: .4em;" rowspan="2"> + <input type="submit" tabindex="3" value="<?php echo $this->t('login_button'); ?>" /> + <input type="hidden" name="RelayState" value="<?php echo htmlspecialchars($this->data['relaystate']); ?>" /> + </td> + </tr> + <tr> + <td style="padding: .3em;"><?php echo $this->t('password'); ?></td> + <td><input type="password" tabindex="2" name="password" /></td> + </tr> + </table> + + + </form> + + + <h2><?php echo $this->t('help_header'); ?></h2> + + + <p><?php echo $this->t('help_text'); ?></p> <?php $this->includeAtTemplateBase('includes/footer.php'); ?> \ No newline at end of file diff --git a/www/auth/login-ldapmulti.php b/www/auth/login-ldapmulti.php index db0661715951ae86502398b54eb28fb1cd35b928..e7ad280eace1194267cbfe966db07af7949d5ab0 100644 --- a/www/auth/login-ldapmulti.php +++ b/www/auth/login-ldapmulti.php @@ -59,7 +59,7 @@ if (isset($_POST['username'])) { exit; } */ - if (!ldap_bind($ds, $dn, $pwd)) { + if (!@ldap_bind($ds, $dn, $pwd)) { $error = 'Bind failed, wrong username or password.' . ' Tried with DN=[' . $dn . '] DNPattern=[' . $ldapconfig['dnpattern'] . '] Error=[' . diff --git a/www/auth/login.php b/www/auth/login.php index c3e31188a01bad6496ca738ac005638290f7834b..900235a77b255de3acf0f32786ff762dbd463ae0 100644 --- a/www/auth/login.php +++ b/www/auth/login.php @@ -46,7 +46,7 @@ if (isset($_POST['username'])) { /* First, make sure that the password field is included. */ if (!array_key_exists('password', $_POST)) { - $error = 'You sent something to the login page, but for some reason the password was not sent. Try again please.'; + $error = 'error_nopassword'; continue; } @@ -67,22 +67,21 @@ if (isset($_POST['username'])) { $ldap = new SimpleSAML_Auth_LDAP($ldapconfig->getValue('auth.ldap.hostname'), $ldapconfig->getValue('auth.ldap.enable_tls')); - /* Insert the LDAP username into the pattern configured in the - * 'auth.ldap.dnpattern' option. + + + + /** + * Insert the LDAP username into the pattern configured in the 'auth.ldap.dnpattern' option. */ - $dn = str_replace('%username%', $ldapusername, - $ldapconfig->getValue('auth.ldap.dnpattern')); + $dn = str_replace('%username%', $ldapusername, $ldapconfig->getValue('auth.ldap.dnpattern')); - /* Connect to the LDAP server. */ - #$ds = ldap_connect($ldapconfig->getValue('auth.ldap.hostname')); - /* * Do LDAP bind using DN found from the the dnpattern */ if (!$ldap->bind($dn, $password)) { SimpleSAML_Logger::info('AUTH - ldap: '. $username . ' failed to authenticate. DN=' . $dn); - throw new Exception('Wrong username or password'); + throw new Exception('error_wrongpassword'); } /* @@ -109,16 +108,11 @@ if (isset($_POST['username'])) { else SimpleSAML_Logger::stats('AUTH-login OK'); - - - + $returnto = $_REQUEST['RelayState']; SimpleSAML_Utilities::redirect($returnto); - - - } catch (Exception $e) { SimpleSAML_Logger::error('AUTH - ldap: User: '.(isset($requestedUser) ? $requestedUser : 'na'). ':'. $e->getMessage()); SimpleSAML_Logger::stats('AUTH-login Failed');