Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Activate and choose new Password Form
Signed-off-by: Guillaume COMPAGNON <[email protected]>
  • Loading branch information
compagnon committed Jul 5, 2019
commit 080f637c452cddd7072bd678baf109c56bf2c25d
3,424 changes: 1,716 additions & 1,708 deletions config/config.sample.php

Large diffs are not rendered by default.

959 changes: 557 additions & 402 deletions core/Controller/LostController.php

Large diffs are not rendered by default.

136 changes: 136 additions & 0 deletions core/js/lostpassword/newpassword.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/**
* Copyright (c) 2019
* Guillaume Compagnon [email protected]
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OC.Newpassword = {

sendErrorMsg : t('core', 'Couldn\'t send reset email. Please contact your administrator.'),

sendSuccessResetPasswordMsg : t('core', 'We have send a password reset e-mail to the e-mail address known to us for this account. If you do not receive it within a reasonable amount of time, check your spam/junk folders.<br>If it is not there ask your local administrator.'),

sendSuccessNewPasswordMsg : t('core', 'We have send a password create e-mail to the e-mail address known to us for this account. If you do not receive it within a reasonable amount of time, check your spam/junk folders.<br>If it is not there ask your local administrator.'),

resetErrorMsg : t('core', 'Password can not be changed. Please contact your administrator.'),

init : function() {
$('form[name=email]').submit(OC.Newpassword.onSendLink);
$('#new-password-close').click(OC.Newpassword.closeWindows);
$('#new-password-submit').click(OC.Newpassword.resetPassword);
OC.Newpassword.resetButtons();
},

resetButtons : function() {
$('#submit-wrapper .submit-icon')
.addClass('icon-confirm-white')
.removeClass('icon-loading-small-dark');
if( $('#action').val() == 'NEW') {
$('#new-password-submit')
.attr('value', t('core', 'First connection'))
.prop('disabled', false);
$('#user').prop('disabled', true);
} else if( $('#action').val() == 'RESET') {
$('#new-password-submit')
.attr('value', t('core', 'Reset password'))
.prop('disabled', false);
$('#user').prop('disabled', false);
}
$('.login-additional').fadeIn();
//$('.new-password-wrapper').fadeIn();
$('form[name=email]').attr('action', 'lostpassword/email');
},

onSendLink: function (event) {
// Only if password reset form is active
if($('form[name=email][action]').length === 1) {
if (event) {
event.preventDefault();
}
$('#submit-wrapper .submit-icon')
.removeClass('icon-confirm-white')
.addClass('icon-loading-small-dark');
$('#new-password-submit')
.attr('value', t('core', 'Sending email …'))
.prop('disabled', true);
$('#user').prop('disabled', true);

$('.login-additional').fadeOut();
$('.new-password-wrapper').slideDown().fadeOut();

$.post(
OC.generateUrl('/lostpassword/email'),
{
user : $('#user').val(),
action : $('#action').val()
},
OC.Newpassword.sendLinkDone
).fail(function() {
OC.Newpassword.sendLinkError(OC.Newpassword.sendErrorMsg);
});
}
},

sendLinkDone : function(result){
var sendErrorMsg;
if (result && result.status === 'success'){
OC.Newpassword.sendLinkSuccess();
} else {
if (result && result.msg){
sendErrorMsg = result.msg;
} else {
sendErrorMsg = OC.Newpassword.sendErrorMsg;
}
OC.Newpassword.sendLinkError(sendErrorMsg);
}
},

sendLinkSuccess : function(msg){
var node = OC.Newpassword.getSendStatusNode();
// update is the better success message styling
node.addClass('update').css({width:'auto'});
if( $('#action').val() == 'NEW') {
node.html(OC.Newpassword.sendSuccessNewPasswordMsg);
$('#action').val('RESET');
} else if ( $('#action').val() == 'RESET') {
node.html(OC.Newpassword.sendSuccessResetPasswordMsg);
}
$('#new-password-close').slideDown().fadeIn();
OC.Newpassword.resetButtons();
},

sendLinkError : function(msg){
var node = OC.Newpassword.getSendStatusNode();
node.addClass('warning');
node.html(msg);
$('#new-password-close').slideDown().fadeIn();
$('#new-password-admin').slideDown().fadeIn();
OC.Newpassword.resetButtons();
},

getSendStatusNode : function(){
if (!$('#new-password').length){
$('<p id="#new-password"></p>').insertBefore($('#new-password-close'));
} else {
$('#new-password').replaceWith($('<p id="new-password"></p>'));
}
return $('#new-password');
},

resetPassword : function(event){

$('#submit-wrapper .submit-icon')
.removeClass('icon-confirm-white')
.addClass(OCA.Theming && OCA.Theming.inverted
? 'icon-loading-small'
: 'icon-loading-small-dark');
},

closeWindows : function(event){
window.close();
},


};

$(document).ready(OC.Newpassword.init);
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.