-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client html side of user password change #152
base: master
Are you sure you want to change the base?
Changes from 1 commit
05f00b4
079280d
8b6fb55
824ed10
3f60921
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ client/html/tests/tmp | |
*.junit.xml | ||
*.log | ||
*.ser | ||
|
||
.idea | ||
vendor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
|
||
namespace Aimeos\Client\Html\Account\Profile\Account; | ||
|
||
use Illuminate\Support\Facades\Log; | ||
|
||
/** | ||
* Default implementation of acount profile address HTML client. | ||
* | ||
* @package Client | ||
* @subpackage Html | ||
*/ | ||
class Standard | ||
extends \Aimeos\Client\Html\Common\Client\Summary\Base | ||
implements \Aimeos\Client\Html\Common\Client\Factory\Iface | ||
{ | ||
|
||
/** client/html/account/profile/address/subparts | ||
* List of HTML sub-clients rendered within the account profile address section | ||
* | ||
* The output of the frontend is composed of the code generated by the HTML | ||
* clients. Each HTML client can consist of serveral (or none) sub-clients | ||
* that are responsible for rendering certain sub-parts of the output. The | ||
* sub-clients can contain HTML clients themselves and therefore a | ||
* hierarchical tree of HTML clients is composed. Each HTML client creates | ||
* the output that is placed inside the container of its parent. | ||
* | ||
* At first, always the HTML code generated by the parent is printed, then | ||
* the HTML code of its sub-clients. The address of the HTML sub-clients | ||
* determines the address of the output of these sub-clients inside the parent | ||
* container. If the configured list of clients is | ||
* | ||
* array( "subclient1", "subclient2" ) | ||
* | ||
* you can easily change the address of the output by readdressing the subparts: | ||
* | ||
* client/html/<clients>/subparts = array( "subclient1", "subclient2" ) | ||
* | ||
* You can also remove one or more parts if they shouldn't be rendered: | ||
* | ||
* client/html/<clients>/subparts = array( "subclient1" ) | ||
* | ||
* As the clients only generates structural HTML, the layout defined via CSS | ||
* should support adding, removing or readdressing content by a fluid like | ||
* design. | ||
* | ||
* @param array List of sub-client names | ||
* @since 2019.07 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update |
||
* @category Developer | ||
*/ | ||
private $subPartPath = 'client/html/account/profile/account/subparts'; | ||
private $subPartNames = []; | ||
|
||
protected function getSubClientNames(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function getSubClient(string $type, string $name = null): \Aimeos\Client\Html\Iface | ||
{ | ||
// TODO: Implement getSubClient() method. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just copy the code from another file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added that |
||
} | ||
|
||
/** | ||
* Returns the HTML code for insertion into the body. | ||
* | ||
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page | ||
* @return string HTML code | ||
*/ | ||
public function getBody(string $uid = ''): string | ||
{ | ||
$view = $this->getView(); | ||
|
||
$html = ''; | ||
foreach( $this->getSubClients() as $subclient ) { | ||
$html .= $subclient->setView( $view )->getBody( $uid ); | ||
} | ||
$view->addressBody = $html; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace all occurrences of "address" by "account" everywhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaced every occurance of "address" |
||
|
||
/** client/html/account/profile/address/template-body | ||
* Relative path to the HTML body template of the account profile address client. | ||
* | ||
* The template file contains the HTML code and processing instructions | ||
* to generate the result shown in the body of the frontend. The | ||
* configuration string is the path to the template file relative | ||
* to the templates directory (usually in client/html/templates). | ||
* | ||
* You can overwrite the template file configuration in extensions and | ||
* provide alternative templates. These alternative templates should be | ||
* named like the default one but with the string "standard" replaced by | ||
* an unique name. You may use the name of your project for this. If | ||
* you've implemented an alternative client class as well, "standard" | ||
* should be replaced by the name of the new class. | ||
* | ||
* @param string Relative path to the template creating code for the HTML page body | ||
* @since 2019.07 | ||
* @category Developer | ||
* @see client/html/account/profile/address/template-header | ||
*/ | ||
$tplconf = 'client/html/account/profile/account/template-body'; | ||
$default = 'account/profile/account-body-standard'; | ||
|
||
return $view->render( $view->config( $tplconf, $default ) ); | ||
} | ||
|
||
/** | ||
* Processes the input, e.g. store given values. | ||
* | ||
* A view must be available and this method doesn't generate any output | ||
* besides setting view variables if necessary. | ||
*/ | ||
public function process() | ||
{ | ||
$view = $this->getView(); | ||
|
||
if( !$view->param( 'account/save' ) ) { | ||
return parent::process(); | ||
} | ||
|
||
/** @var \Aimeos\Controller\Frontend\Customer\Standard $cntl */ | ||
$cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'customer' ); | ||
$oldPassword = $cntl->get()->getPassword(); | ||
$values = $view->param('account', []); | ||
|
||
$isNew = $values['customer.newpassword'] !== $values['customer.oldpassword']; | ||
$confirmed = $values['customer.newpassword'] === $values['customer.confirmnewpassword']; | ||
|
||
$errors = []; | ||
|
||
if (!$isNew) { | ||
$errors['isNew'] = "The given password is not new!"; | ||
} | ||
|
||
if (!$confirmed) { | ||
$errors["confirm"] = "New passwords doesnt match!"; | ||
} | ||
|
||
$cntl = $cntl->add($values); | ||
|
||
if ( $oldPassword === $cntl->get()->getPassword() ) { | ||
$errors['oldPassword'] = "Wrong password!"; | ||
} | ||
|
||
$view->passwordChanged = count(array_keys($errors)) === 0; | ||
|
||
if (count(array_keys($errors)) > 0) { | ||
$view->passwordErrors = $errors; | ||
} | ||
|
||
$cntl->store(); | ||
|
||
parent::process(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<?php | ||
|
||
$enc = $this->encoder(); | ||
|
||
/** client/html/account/profile/url/target | ||
* Destination of the URL where the controller specified in the URL is known | ||
* | ||
* The destination can be a page ID like in a content management system or the | ||
* module of a software development framework. This "target" must contain or know | ||
* the controller that should be called by the generated URL. | ||
* | ||
* @param string Destination of the URL | ||
* @since 2019.10 | ||
* @category Developer | ||
* @see client/html/account/profile/url/controller | ||
* @see client/html/account/profile/url/action | ||
* @see client/html/account/profile/url/config | ||
*/ | ||
|
||
/** client/html/account/profile/url/controller | ||
* Name of the controller whose action should be called | ||
* | ||
* In Model-View-Controller (MVC) applications, the controller contains the methods | ||
* that create parts of the output displayed in the generated HTML page. Controller | ||
* names are usually alpha-numeric. | ||
* | ||
* @param string Name of the controller | ||
* @since 2019.10 | ||
* @category Developer | ||
* @see client/html/account/profile/url/target | ||
* @see client/html/account/profile/url/action | ||
* @see client/html/account/profile/url/config | ||
*/ | ||
|
||
/** client/html/account/profile/url/action | ||
* Name of the action that should create the output | ||
* | ||
* In Model-View-Controller (MVC) applications, actions are the methods of a | ||
* controller that create parts of the output displayed in the generated HTML page. | ||
* Action names are usually alpha-numeric. | ||
* | ||
* @param string Name of the action | ||
* @since 2019.10 | ||
* @category Developer | ||
* @see client/html/account/profile/url/target | ||
* @see client/html/account/profile/url/controller | ||
* @see client/html/account/profile/url/config | ||
*/ | ||
|
||
/** client/html/account/profile/url/config | ||
* Associative list of configuration options used for generating the URL | ||
* | ||
* You can specify additional options as key/value pairs used when generating | ||
* the URLs, like | ||
* | ||
* client/html/<clientname>/url/config = array( 'absoluteUri' => true ) | ||
* | ||
* The available key/value pairs depend on the application that embeds the e-commerce | ||
* framework. This is because the infrastructure of the application is used for | ||
* generating the URLs. The full list of available config options is referenced | ||
* in the "see also" section of this page. | ||
* | ||
* @param string Associative list of configuration options | ||
* @since 2019.10 | ||
* @category Developer | ||
* @see client/html/account/profile/url/target | ||
* @see client/html/account/profile/url/controller | ||
* @see client/html/account/profile/url/action | ||
* @see client/html/url/config | ||
*/ | ||
|
||
/** client/html/account/profile/url/filter | ||
* Removes parameters for the detail page before generating the URL | ||
* | ||
* For SEO, it's nice to have URLs which contains only required parameters. | ||
* This setting removes the listed parameters from the URLs. Keep care to | ||
* remove no required parameters! | ||
* | ||
* @param array List of parameter names to remove | ||
* @since 2019.10 | ||
* @category User | ||
* @category Developer | ||
* @see client/html/account/profile/url/target | ||
* @see client/html/account/profile/url/controller | ||
* @see client/html/account/profile/url/action | ||
* @see client/html/account/profile/url/config | ||
*/ | ||
|
||
$passwordErrors = $this->get('passwordErrors', []); | ||
|
||
?> | ||
<?php $this->block()->start( 'account/profile/account' ) ?> | ||
|
||
<div class="account-profile-account"> | ||
<h1 class="header"><?= $enc->html( $this->translate( 'client', 'account' ) ) ?></h1> | ||
<form class="container-fluid" method="POST" action="<?= $enc->attr( $this->link( 'client/html/account/profile/url' ) ) ?>"> | ||
<?= $this->csrf()->formfield() ?> | ||
<?php if ( $this->get('passwordChanged', '') === 'true' ) : ?> | ||
<div class="row d-flex justify-content-center"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Utility CSS classes are handy but a bad idea if different themes have to cope with them. Please add the necessary styles to the CSS file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed that |
||
<h2 class="text-success">Password changed successfull!</h2> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All strings need to be translated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
</div> | ||
<?php elseif ($this->get('passwordChanged', '') === 'false') :?> | ||
<div class="row d-flex justify-content-center"> | ||
<h2 class="text-danger">Error(s) occured!</h2> | ||
</div> | ||
<?php endif ?> | ||
<div class="row"> | ||
<div class="password col-lg-12"> | ||
<h2 class="header"><?= $enc->html( $this->translate( 'client', 'Password' ) ) ?></h2> | ||
<div class="panel panel-default password-change"> | ||
<div class="form-item form-group row old-password"> | ||
|
||
<label class="col-md-4" for="old-password"> | ||
<?= $enc->html( $this->translate( 'client', 'Old password' ), $enc::TRUST ) ?> | ||
</label> | ||
<div class="col-md-8"> | ||
<input class="form-control" type="password" | ||
id="old-password" | ||
name="<?= $enc->attr( $this->formparam( array( 'account', 'customer.oldpassword' ) ) ) ?>" | ||
placeholder="<?= $enc->attr( $this->translate( 'client', 'Old password' ) ) ?>" | ||
> | ||
<?php if( isset($passwordErrors['oldPassword']) ) : ?> | ||
<span class="invalid-feedback d-block" role="alert"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No Bootstrap utitlity classes ( |
||
<strong><?= $passwordErrors['oldPassword'] ?></strong> | ||
</span> | ||
<?php endif ?> | ||
</div> | ||
|
||
</div> | ||
<div class="form-item form-group row new-password"> | ||
|
||
<label class="col-md-4" for="new-password"> | ||
<?= $enc->html( $this->translate( 'client', 'New password' ), $enc::TRUST ) ?> | ||
</label> | ||
<div class="col-md-8"> | ||
<input class="form-control" type="password" | ||
id="new-password" | ||
name="<?= $enc->attr( $this->formparam( array( 'account', 'customer.newpassword' ) ) ) ?>" | ||
placeholder="<?= $enc->attr( $this->translate( 'client', 'New password' ) ) ?>" | ||
> | ||
<?php if( isset($passwordErrors['confirm']) ) : ?> | ||
<span class="invalid-feedback d-block" role="alert"> | ||
<strong><?= $passwordErrors['confirm'] ?></strong> | ||
</span> | ||
<?php endif ?> | ||
<?php if( isset($passwordErrors['isNew']) ) : ?> | ||
<span class="invalid-feedback d-block" role="alert"> | ||
<strong><?= $passwordErrors['isNew'] ?></strong> | ||
</span> | ||
<?php endif ?> | ||
</div> | ||
|
||
</div> | ||
<div class="form-item form-group row old-password"> | ||
|
||
<label class="col-md-4" for="confirm-new-password"> | ||
<?= $enc->html( $this->translate( 'client', 'Confirm password' ), $enc::TRUST ) ?> | ||
</label> | ||
<div class="col-md-8"> | ||
<input class="form-control" type="password" | ||
id="confirm-new-password" | ||
name="<?= $enc->attr( $this->formparam( array( 'account', 'customer.confirmnewpassword' ) ) ) ?>" | ||
placeholder="<?= $enc->attr( $this->translate( 'client', 'Confirm password' ) ) ?>" | ||
> | ||
<?php if( isset($passwordErrors['confirm']) ) : ?> | ||
<span class="invalid-feedback d-block" role="alert"> | ||
<strong><?= $passwordErrors['confirm'] ?></strong> | ||
</span> | ||
<?php endif ?> | ||
<?php if( isset($passwordErrors['isNew']) ) : ?> | ||
<span class="invalid-feedback d-block" role="alert"> | ||
<strong><?= $passwordErrors['isNew'] ?></strong> | ||
</span> | ||
<?php endif ?> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="button-group"> | ||
<button class="btn btn-cancel" value="1" type="reset"> | ||
<?= $enc->html( $this->translate( 'client', 'Cancel' ), $enc::TRUST ) ?> | ||
</button> | ||
<button class="btn btn-primary btn-save" value="1" name="<?= $enc->attr( $this->formparam( array( 'account', 'save' ) ) ) ?>"> | ||
<?= $enc->html( $this->translate( 'client', 'Change password' ), $enc::TRUST ) ?> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change that to
Aimeos\Client\Html\Account\Profile\Password
instead?