mirror of
https://github.com/dducret/kopano-webapp-passwd
synced 2026-08-06 15:33:14 +02:00
Instead of adding a button in top bar, create a settings category to change password
some restructuring of files
This commit is contained in:
parent
d55b22e255
commit
72304986fc
6 changed files with 25 additions and 237 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
Ext.namespace('Zarafa.plugins.passwd');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class Zarafa.plugins.passwd.PasswdContentPanel
|
|
||||||
* @extends Zarafa.core.ui.ContentPanel
|
|
||||||
*
|
|
||||||
* Content panel that will layout the container
|
|
||||||
*/
|
|
||||||
Zarafa.plugins.passwd.PasswdContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {Object} config configuration object that needs to be used when creating this dialog
|
|
||||||
*/
|
|
||||||
constructor : function(config)
|
|
||||||
{
|
|
||||||
config = config || {};
|
|
||||||
|
|
||||||
Ext.applyIf(config, {
|
|
||||||
xtype : 'zarafa.passwdcontentpanel',
|
|
||||||
layout : 'fit',
|
|
||||||
height : 175,
|
|
||||||
width : 400,
|
|
||||||
title : _('Change password'),
|
|
||||||
items : [{
|
|
||||||
xtype : 'zarafa.passwdpanel'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
Zarafa.plugins.passwd.PasswdContentPanel.superclass.constructor.apply(this, arguments);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ext.reg('zarafa.passwdcontentpanel', Zarafa.plugins.passwd.PasswdContentPanel);
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
Ext.namespace('Zarafa.plugins.passwd');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class Zarafa.plugins.passwd.PasswdPanel
|
|
||||||
* @extends Ext.form.FormPanel
|
|
||||||
*
|
|
||||||
* Panel which holds a form that will be used to change the password
|
|
||||||
*/
|
|
||||||
Zarafa.plugins.passwd.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|
||||||
/**
|
|
||||||
* @property
|
|
||||||
* @type Ext.LoadMask
|
|
||||||
* Save mask that will be displayed when request has been sent to server for password change
|
|
||||||
* and waiting for the response.
|
|
||||||
*/
|
|
||||||
saveMask : undefined,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {Object} config configuration object that needs to be used when creating this dialog
|
|
||||||
*/
|
|
||||||
constructor : function(config)
|
|
||||||
{
|
|
||||||
config = config || {};
|
|
||||||
|
|
||||||
Ext.applyIf(config, {
|
|
||||||
xtype : 'zarafa.passwdpanel',
|
|
||||||
labelWidth : 150,
|
|
||||||
defaults : {
|
|
||||||
width : 200
|
|
||||||
},
|
|
||||||
items : [{
|
|
||||||
xtype : 'displayfield',
|
|
||||||
ref : 'userNameField',
|
|
||||||
fieldLabel : 'User name'
|
|
||||||
}, {
|
|
||||||
xtype : 'textfield',
|
|
||||||
ref : 'oldPasswdField',
|
|
||||||
fieldLabel : 'Current password',
|
|
||||||
inputType : 'password'
|
|
||||||
}, {
|
|
||||||
xtype : 'textfield',
|
|
||||||
ref : 'newPasswdField',
|
|
||||||
fieldLabel : 'New password',
|
|
||||||
inputType : 'password'
|
|
||||||
}, {
|
|
||||||
xtype : 'textfield',
|
|
||||||
ref : 'newPasswdRepeatField',
|
|
||||||
fieldLabel : 'Retype new password',
|
|
||||||
inputType : 'password'
|
|
||||||
}],
|
|
||||||
buttons : [{
|
|
||||||
text : 'Ok',
|
|
||||||
handler : this.onOk,
|
|
||||||
scope : this
|
|
||||||
}, {
|
|
||||||
text : 'Cancel',
|
|
||||||
handler : this.onCancel,
|
|
||||||
scope : this
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
Zarafa.plugins.passwd.PasswdPanel.superclass.constructor.apply(this, arguments);
|
|
||||||
|
|
||||||
this.on('afterrender', this.initialize, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function will initialize this dialog with some default values and will
|
|
||||||
* also create object of {@link #saveMask}.
|
|
||||||
*/
|
|
||||||
initialize : function()
|
|
||||||
{
|
|
||||||
this.userNameField.setValue(container.getUser().getUserName());
|
|
||||||
|
|
||||||
this.saveMask = new Ext.LoadMask(this.getEl(), {
|
|
||||||
msg : _('Saving please wait ...')
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler function that will be called when user presses ok button
|
|
||||||
* to change password.
|
|
||||||
*/
|
|
||||||
onOk : function()
|
|
||||||
{
|
|
||||||
// show load mask
|
|
||||||
this.saveMask.show();
|
|
||||||
|
|
||||||
// send request
|
|
||||||
container.getRequest().singleRequest('passwdmodule', 'save', {
|
|
||||||
username : this.userNameField.getValue(),
|
|
||||||
current_password : this.oldPasswdField.getValue(),
|
|
||||||
new_password : this.newPasswdField.getValue(),
|
|
||||||
new_password_repeat : this.newPasswdRepeatField.getValue()
|
|
||||||
}, new Zarafa.plugins.passwd.data.PasswdResponseHandler({
|
|
||||||
callbackFn : this.callbackFn,
|
|
||||||
scope : this
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler function that will be called when user presses cancel button
|
|
||||||
* to close the dialog.
|
|
||||||
*/
|
|
||||||
onCancel : function()
|
|
||||||
{
|
|
||||||
// close the dialog
|
|
||||||
this.dialog.close();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback function that will be executed after response is received from server.
|
|
||||||
* @param {Boolean} success boolean to indicate response contains success/failure data.
|
|
||||||
* @param {Object} response response sent by server.
|
|
||||||
*/
|
|
||||||
callbackFn : function(success, response)
|
|
||||||
{
|
|
||||||
// hide load mask
|
|
||||||
this.saveMask.hide();
|
|
||||||
|
|
||||||
// close the dialog
|
|
||||||
if(success) {
|
|
||||||
this.dialog.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ext.reg('zarafa.passwdpanel', Zarafa.plugins.passwd.PasswdPanel);
|
|
||||||
|
|
@ -18,77 +18,29 @@ Zarafa.plugins.passwd.PasswdPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||||
{
|
{
|
||||||
Zarafa.plugins.passwd.PasswdPlugin.superclass.initPlugin.apply(this, arguments);
|
Zarafa.plugins.passwd.PasswdPlugin.superclass.initPlugin.apply(this, arguments);
|
||||||
|
|
||||||
this.registerInsertionPoint('main.maintabbar.right', this.putTabbarButton, this);
|
// Register categories for the settings
|
||||||
|
this.registerInsertionPoint('context.settings.categories', this.createSettingsCategory, this);
|
||||||
// Register common specific dialog types
|
|
||||||
Zarafa.core.data.SharedComponentType.addProperty('plugins.passwd.passwdpanel');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bid for the type of shared component and the given record.
|
* Create the delegate {@link Zarafa.settings.ui.SettingsCategory Settings Category}
|
||||||
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
|
* to the {@link Zarafa.settings.SettingsContext}. This will create new
|
||||||
* @param {Ext.data.Record} record Optionally passed record.
|
* {@link Zarafa.settings.ui.SettingsCategoryTab tabs} for the
|
||||||
* @return {Number} The bid for the shared component
|
* {@link Zarafa.calendar.ui.SettingsPasswdCategory Password}
|
||||||
*/
|
* in the {@link Zarafa.settings.ui.SettingsCategoryWidgetPanel Widget Panel}.
|
||||||
bidSharedComponent: function(type, record)
|
* @param {String} insertionName insertion point name that is currently populated
|
||||||
{
|
* @param {Zarafa.settings.ui.SettingsMainPanel} settingsMainPanel settings main panel
|
||||||
var bid = -1;
|
* which is populating this insertion point
|
||||||
|
* @param {Zarafa.settings.SettingsContext} settingsContext settings context
|
||||||
switch (type) {
|
* @return {Array} configuration object for the categories to register
|
||||||
// Bid for password dialog
|
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.passwd.passwdpanel']:
|
|
||||||
bid = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bid;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return the reference to the shared component.
|
|
||||||
* Based on the type of component requested a component is returned.
|
|
||||||
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
|
|
||||||
* @param {Ext.data.Record} record Optionally passed record.
|
|
||||||
* @return {Ext.Component} Component
|
|
||||||
*/
|
|
||||||
getSharedComponent: function(type, record)
|
|
||||||
{
|
|
||||||
var component;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.passwd.passwdpanel']:
|
|
||||||
component = Zarafa.plugins.passwd.PasswdContentPanel;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return component;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the button to add to the insertion point as called
|
|
||||||
* by init().
|
|
||||||
* @return A struct with the necessary configuration for the button.
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
putTabbarButton : function()
|
createSettingsCategory : function(insertionName, settingsMainPanel, settingsContext)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
text : _('Change Password'),
|
xtype : 'zarafa.settingspasswdcategory',
|
||||||
handler : this.clickPasswdButton
|
settingsContext : settingsContext
|
||||||
};
|
};
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trigger function called when the user clicks the button in the
|
|
||||||
* main tab bar.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
clickPasswdButton : function()
|
|
||||||
{
|
|
||||||
var componentType = Zarafa.core.data.SharedComponentType['plugins.passwd.passwdpanel'];
|
|
||||||
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, {
|
|
||||||
modal : true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
10
manifest.xml
10
manifest.xml
|
|
@ -6,7 +6,7 @@
|
||||||
<name>Passwd</name>
|
<name>Passwd</name>
|
||||||
<title>Password Changer Plugin</title>
|
<title>Password Changer Plugin</title>
|
||||||
<author>Saket Patel</author>
|
<author>Saket Patel</author>
|
||||||
<authorURL>http://www.zarafa.com</authorURL>
|
<authorURL>https://github.com/silentsakky</authorURL>
|
||||||
<description>Change your password from zarafa webapp</description>
|
<description>Change your password from zarafa webapp</description>
|
||||||
</info>
|
</info>
|
||||||
<config>
|
<config>
|
||||||
|
|
@ -36,14 +36,12 @@
|
||||||
<clientfile load="release">js/passwd.js</clientfile>
|
<clientfile load="release">js/passwd.js</clientfile>
|
||||||
<clientfile load="debug">js/passwd-debug.js</clientfile>
|
<clientfile load="debug">js/passwd-debug.js</clientfile>
|
||||||
<clientfile load="source">js/PasswdPlugin.js</clientfile>
|
<clientfile load="source">js/PasswdPlugin.js</clientfile>
|
||||||
<clientfile load="source">js/PasswdContentPanel.js</clientfile>
|
<clientfile load="source">js/settings/SettingsPasswdCategory.js</clientfile>
|
||||||
<clientfile load="source">js/PasswdPanel.js</clientfile>
|
<clientfile load="source">js/settings/SettingsPasswdWidget.js</clientfile>
|
||||||
|
<clientfile load="source">js/settings/PasswdPanel.js</clientfile>
|
||||||
<clientfile load="source">js/data/PasswdResponseHandler.js</clientfile>
|
<clientfile load="source">js/data/PasswdResponseHandler.js</clientfile>
|
||||||
<clientfile load="source">js/ABOUT.js</clientfile>
|
<clientfile load="source">js/ABOUT.js</clientfile>
|
||||||
</client>
|
</client>
|
||||||
<!-- <resources>
|
|
||||||
<resourcefile load="release">resources/css/passwd.css</resourcefile>
|
|
||||||
</resources> -->
|
|
||||||
</files>
|
</files>
|
||||||
</component>
|
</component>
|
||||||
</components>
|
</components>
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class PasswdModule extends Module
|
||||||
$errorMessage = _('No data received.');
|
$errorMessage = _('No data received.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($data['username']) || empty($data['current_password']) || empty($data['new_password']) || empty($data['new_password_repeat'])) {
|
if(empty($data['username'])) {
|
||||||
$errorMessage = _('User name is empty.');
|
$errorMessage = _('User name is empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,9 +160,9 @@ class PasswdModule extends Module
|
||||||
$passwd = $data['new_password'];
|
$passwd = $data['new_password'];
|
||||||
$passwdRepeat = $data['new_password_repeat'];
|
$passwdRepeat = $data['new_password_repeat'];
|
||||||
|
|
||||||
|
if($this->checkPasswordStrenth($passwd)) {
|
||||||
$passwd_cmd = "/usr/bin/zarafa-passwd -u %s -o %s -p %s";
|
$passwd_cmd = "/usr/bin/zarafa-passwd -u %s -o %s -p %s";
|
||||||
|
|
||||||
if($this->checkPasswordStrenth($passwd)) {
|
|
||||||
// all information correct, change password
|
// all information correct, change password
|
||||||
$cmd = sprintf($passwd_cmd, $data['username'], $data['current_password'], $passwd);
|
$cmd = sprintf($passwd_cmd, $data['username'], $data['current_password'], $passwd);
|
||||||
exec($cmd, $arrayout, $retval);
|
exec($cmd, $arrayout, $retval);
|
||||||
|
|
@ -203,6 +203,7 @@ class PasswdModule extends Module
|
||||||
*/
|
*/
|
||||||
public function checkPasswordStrenth($password)
|
public function checkPasswordStrenth($password)
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
// @FIXME should be moved to client side
|
// @FIXME should be moved to client side
|
||||||
if (preg_match("#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$#", $password)) {
|
if (preg_match("#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$#", $password)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* Allows to change user password from webapp.
|
* Allows to change user password from webapp.
|
||||||
*
|
*
|
||||||
* Author: Saket patel <silentsakky@gmail.com>
|
* Author: Saket patel <s.patel@zarafa.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Pluginpasswd extends Plugin {
|
class Pluginpasswd extends Plugin {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue