forked from extern/egroupware
Nicer password widget on account edit dialog
- Added plain-text attribute to avoid encrypting password - Suggest password now fills both fields the same
This commit is contained in:
parent
8020464dde
commit
d7d5837ecf
@ -905,10 +905,20 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
*/
|
||||
AddressbookApp.prototype.account_change = function (_ev, _widget) {
|
||||
switch (_widget.id) {
|
||||
case 'account_passwd':
|
||||
debugger;
|
||||
// If they clicked suggest, copy it to password 2
|
||||
if (_widget && _widget.options.viewable) {
|
||||
var p2 = _widget.getParent().getWidgetById('account_passwd_2');
|
||||
p2.set_viewable(true); // Allow viewing password
|
||||
p2.toggle_visibility(true); // Actually show it
|
||||
p2.set_value(_widget.getValue());
|
||||
_widget.options.viewable = false;
|
||||
}
|
||||
// Fall through
|
||||
case 'account_lid':
|
||||
case 'n_family':
|
||||
case 'n_given':
|
||||
case 'account_passwd':
|
||||
case 'account_passwd_2':
|
||||
var values = this.et2._inst.getValues(this.et2);
|
||||
var data = {
|
||||
|
@ -1101,10 +1101,21 @@ class AddressbookApp extends EgwApp
|
||||
{
|
||||
switch(_widget.id)
|
||||
{
|
||||
case 'account_passwd':
|
||||
debugger;
|
||||
// If they clicked suggest, copy it to password 2
|
||||
if(_widget && _widget.options.viewable)
|
||||
{
|
||||
let p2 = _widget.getParent().getWidgetById('account_passwd_2');
|
||||
p2.set_viewable(true); // Allow viewing password
|
||||
p2.toggle_visibility(true); // Actually show it
|
||||
p2.set_value(_widget.getValue());
|
||||
_widget.options.viewable = false;
|
||||
}
|
||||
// Fall through
|
||||
case 'account_lid':
|
||||
case 'n_family':
|
||||
case 'n_given':
|
||||
case 'account_passwd':
|
||||
case 'account_passwd_2':
|
||||
var values = this.et2._inst.getValues(this.et2);
|
||||
var data = {
|
||||
|
@ -26,10 +26,10 @@
|
||||
</row>
|
||||
<row>
|
||||
<description value="Password" for="account_passwd"/>
|
||||
<passwd id="account_passwd" class="et2_fullWidth" onchange="app.addressbook.account_change" autocomplete="new-password"/>
|
||||
<passwd id="account_passwd" class="et2_fullWidth" onchange="app.addressbook.account_change" autocomplete="new-password" plaintext="true"/>
|
||||
<description/>
|
||||
<description value="Re-enter password" for="account_passwd_2"/>
|
||||
<passwd id="account_passwd_2" class="et2_fullWidth" onchange="app.addressbook.account_change"/>
|
||||
<passwd id="account_passwd_2" class="et2_fullWidth" onchange="app.addressbook.account_change" plaintext="true" suggest="0"/>
|
||||
<description/>
|
||||
</row>
|
||||
<row valign="top">
|
||||
|
@ -49,6 +49,9 @@ var et2_password = /** @class */ (function (_super) {
|
||||
// The password is stored encrypted server side, and passed encrypted.
|
||||
// This flag is for if we've decrypted the password to show it already
|
||||
_this.encrypted = true;
|
||||
if (_this.options.plaintext) {
|
||||
_this.encrypted = false;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
et2_password.prototype.createInputWidget = function () {
|
||||
@ -217,6 +220,7 @@ var et2_password = /** @class */ (function (_super) {
|
||||
var request = egw.json("EGroupware\\Api\\Etemplate\\Widget\\Password::ajax_suggest", [this.options.suggest], function (suggestion) {
|
||||
this.encrypted = false;
|
||||
this.input.val(suggestion);
|
||||
this.input.trigger('change');
|
||||
}, this, true, this).sendRequest();
|
||||
};
|
||||
et2_password.prototype.destroy = function () {
|
||||
@ -238,6 +242,12 @@ var et2_password = /** @class */ (function (_super) {
|
||||
"default": false,
|
||||
"description": "Allow password to be shown"
|
||||
},
|
||||
"plaintext": {
|
||||
name: "Plaintext",
|
||||
type: "boolean",
|
||||
default: false,
|
||||
description: "Password is plaintext"
|
||||
},
|
||||
"suggest": {
|
||||
name: "Suggest password",
|
||||
type: "integer",
|
||||
|
@ -43,6 +43,12 @@ export class et2_password extends et2_textbox
|
||||
"default": false,
|
||||
"description": "Allow password to be shown"
|
||||
},
|
||||
"plaintext": {
|
||||
name: "Plaintext",
|
||||
type: "boolean",
|
||||
default: false,
|
||||
description: "Password is plaintext"
|
||||
},
|
||||
"suggest": {
|
||||
name: "Suggest password",
|
||||
type: "integer",
|
||||
@ -68,6 +74,10 @@ export class et2_password extends et2_textbox
|
||||
// Call the inherited constructor
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_password._attributes, _child || {}));
|
||||
|
||||
if(this.options.plaintext)
|
||||
{
|
||||
this.encrypted = false;
|
||||
}
|
||||
}
|
||||
|
||||
createInputWidget()
|
||||
@ -289,6 +299,7 @@ export class et2_password extends et2_textbox
|
||||
function(suggestion) {
|
||||
this.encrypted = false;
|
||||
this.input.val(suggestion);
|
||||
this.input.trigger('change');
|
||||
},
|
||||
this,true,this
|
||||
).sendRequest();
|
||||
|
@ -48,12 +48,14 @@ class Password extends Etemplate\Widget\Textbox
|
||||
{
|
||||
$form_name = self::form_name($cname, $this->id, $expand);
|
||||
$value =& self::get_array(self::$request->content, $form_name);
|
||||
$plaintext = 'true' == self::expand_name($this->attrs['plaintext'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
|
||||
|
||||
if (!empty($value))
|
||||
{
|
||||
$preserv =& self::get_array(self::$request->preserv, $form_name, true);
|
||||
$preserv = (string)$value;
|
||||
|
||||
if (!empty($value) && array_key_exists('viewable', $this->attrs) && $this->attrs['viewable'] == 'false')
|
||||
if (!empty($value) && ((array_key_exists('viewable', $this->attrs) && $this->attrs['viewable'] === 'false') || $plaintext))
|
||||
{
|
||||
$value = str_repeat('*', strlen($preserv));
|
||||
}
|
||||
@ -76,7 +78,7 @@ class Password extends Etemplate\Widget\Textbox
|
||||
public function validate($cname, array $expand, array $content, &$validated=array())
|
||||
{
|
||||
$form_name = self::form_name($cname, $this->id, $expand);
|
||||
|
||||
$plaintext = 'true' == self::expand_name($this->attrs['plaintext'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
|
||||
if (!$this->is_readonly($cname, $form_name))
|
||||
{
|
||||
$value = $value_in = self::get_array($content, $form_name);
|
||||
@ -88,12 +90,12 @@ class Password extends Etemplate\Widget\Textbox
|
||||
{
|
||||
$value = $preserv;
|
||||
}
|
||||
else if ($value_in == Credentials::decrypt(array('cred_password' => $preserv,'cred_pw_enc' => Credentials::SYSTEM_AES)))
|
||||
else if (!$plaintext && $preserv && $value_in == Credentials::decrypt(array('cred_password' => $preserv,'cred_pw_enc' => Credentials::SYSTEM_AES)))
|
||||
{
|
||||
// Don't change if they submitted the decrypted version
|
||||
$value = $preserv;
|
||||
}
|
||||
else if ($value_in !== $preserv)
|
||||
else if (!$plaintext && $value_in !== $preserv)
|
||||
{
|
||||
// Store encrypted
|
||||
$encryption = null;
|
||||
|
Loading…
Reference in New Issue
Block a user