Skip to content

Commit

Permalink
try and not require a password change on user edit
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGoodwin committed Jun 25, 2021
1 parent 2eb02cc commit 8358661
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions include/Form/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User implements Form {
*/
protected $form;

public function __construct(array $data = []) {
public function __construct(array $data = [], $is_new = false) {

$this->form = new \Zend_Form();

Expand All @@ -32,19 +32,19 @@ public function __construct(array $data = []) {

$email = new \Zend_Form_Element_Text('email');
$email->setRequired(false);
$email->setLabel('Email address');
$email->setLabel('Email address');

$email->addValidator(new \Zend_Validate_StringLength([1, 100]));
$email->addValidator(new \Zend_Validate_EmailAddress());



$password = new \Zend_Form_Element_Text('password');
if(empty($data)) {
$password->setRequired(false);
if($is_new) {
$password->setRequired(true);
}
$password->addValidator(new \Zend_Validate_StringLength([0,100]));
$password->setLabel('Password');
$password->addValidator(new \Zend_Validate_StringLength([1,100]));


$uid_select = new \Zend_Form_Element_Select('uid');
Expand All @@ -68,7 +68,7 @@ public function __construct(array $data = []) {

$this->form->addElement($submit);

if(!empty($data)) {
if(!empty($data)) {
$this->form->isValid($data);
}

Expand Down
6 changes: 5 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@

$what = 'New User';
$user = [];
$is_new = true;

if (isset($_REQUEST['username'])) {
$what = 'Edit User';
$user = $model->getUserByUsername($_REQUEST['username']);
if(!empty($user)) {
$is_new = false;
}
}

$template = new \PureFTPAdmin\Template($what);

$form = new PureFTPAdmin\Form\User();
$form = new PureFTPAdmin\Form\User([], $is_new);

$form->setGidList($model->getGidList());
$form->setUidList($model->getUidList());
Expand Down

0 comments on commit 8358661

Please sign in to comment.