Merge pull request #20996 from owncloud/issue-12215-remove-password-reset-when-not-possible

Issue 12215 remove password reset when not possible
This commit is contained in:
Thomas Müller 2015-12-07 19:55:26 +01:00
commit 4100263bd6
5 changed files with 31 additions and 6 deletions

View File

@ -213,6 +213,14 @@ $CONFIG = array(
)
),
/**
* If your user backend does not allow to reset the password (e.g. when it's a
* read-only user backend like LDAP), you can specify a custom link, where the
* user is redirected to, when clicking the "reset password" link after a failed
* login-attempt.
*/
'lost_password_link' => 'https://example.org/link/to/password/reset',
/**
* Mail Parameters
*

View File

@ -141,6 +141,7 @@ $array = array(
'version' => implode('.', OC_Util::getVersion()),
'versionstring' => OC_Util::getVersionString(),
'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true),
'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null),
'modRewriteWorking' => (getenv('front_controller_active') === 'true'),
)
),

View File

@ -13,22 +13,26 @@ OC.Lostpassword = {
resetErrorMsg : t('core', 'Password can not be changed. Please contact your administrator.'),
init : function() {
$('#lost-password').click(OC.Lostpassword.sendLink);
$('#lost-password').click(OC.Lostpassword.resetLink);
$('#reset-password #submit').click(OC.Lostpassword.resetPassword);
},
sendLink : function(event){
resetLink : function(event){
event.preventDefault();
if (!$('#user').val().length){
$('#submit').trigger('click');
} else {
$.post(
if (OC.config['lost_password_link']) {
window.location = OC.config['lost_password_link'];
} else {
$.post(
OC.generateUrl('/lostpassword/email'),
{
user : $('#user').val()
},
OC.Lostpassword.sendLinkDone
);
);
}
}
},

View File

@ -56,11 +56,15 @@ script('core', [
<input type="submit" id="submit" class="login primary icon-confirm svg" title="<?php p($l->t('Log in')); ?>" value="" disabled="disabled"/>
</p>
<?php if (isset($_['invalidpassword']) && ($_['invalidpassword'])): ?>
<?php if (!empty($_['invalidpassword']) && !empty($_['canResetPassword'])) { ?>
<a id="lost-password" class="warning" href="">
<?php p($l->t('Wrong password. Reset it?')); ?>
</a>
<?php endif; ?>
<?php } else if (!empty($_['invalidpassword'])) { ?>
<p class="warning">
<?php p($l->t('Wrong password.')); ?>
</p>
<?php } ?>
<?php if ($_['rememberLoginAllowed'] === true) : ?>
<div class="remember-login-container">
<input type="checkbox" name="remember_login" value="1" id="remember_login" class="checkbox checkbox--white">

View File

@ -947,6 +947,14 @@ class OC_Util {
$parameters['redirect_url'] = $_REQUEST['redirect_url'];
}
$parameters['canResetPassword'] = true;
if (!\OC::$server->getSystemConfig()->getValue('lost_password_link')) {
$user = \OC::$server->getUserManager()->get($_REQUEST['user']);
if ($user instanceof IUser) {
$parameters['canResetPassword'] = $user->canChangePassword();
}
}
$parameters['alt_login'] = OC_App::getAlternativeLogIns();
$parameters['rememberLoginAllowed'] = self::rememberLoginAllowed();
\OC_Hook::emit('OC_Util', 'pre_displayLoginPage', array('parameters' => $parameters));