]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow specifying a custom reset-password-url
authorJoas Schilling <nickvergessen@owncloud.com>
Mon, 7 Dec 2015 14:37:26 +0000 (15:37 +0100)
committerJoas Schilling <nickvergessen@owncloud.com>
Mon, 7 Dec 2015 14:41:40 +0000 (15:41 +0100)
config/config.sample.php
core/js/config.php
core/js/lostpassword.js
lib/private/util.php

index 034a1ebddbf098c26bdc12663dec3e7ff3d9e115..c3abe3a2b8759afc58760aec9e61156a992fe677 100644 (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
  *
index 8956689e74e5cad3fee2b65de0158ca224fab72e..e51ae903729672c20aff02ec204aab040e8fbaa1 100644 (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'),
                )
        ),
index 294a9d8c1cf6e430a36eda89beccacfcf17d485e..df28c2308cb39e7b6fe90aedaaf6a5ca485c3c66 100644 (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
-                       );
+                               );
+                       }
                }
        },
 
index 532730998c6528dc3b52b4cecd97aa396d30aa42..c31ad63b9be2531506aec4536e326851fcfb6496 100644 (file)
@@ -948,9 +948,11 @@ class OC_Util {
                }
 
                $parameters['canResetPassword'] = true;
-               $user = \OC::$server->getUserManager()->get($_REQUEST['user']);
-               if ($user instanceof IUser) {
-                       $parameters['canResetPassword'] = $user->canChangePassword();
+               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();