change password url
This commit is contained in:
@@ -55,22 +55,16 @@ class User extends \Espo\Core\Controllers\Record
|
||||
return $this->getAclManager()->getMap($user);
|
||||
}
|
||||
|
||||
public function actionChangeOwnPassword($params, $data, $request)
|
||||
public function postActionChangeOwnPassword($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (!array_key_exists('password', $data) || !array_key_exists('currentPassword', $data)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('User')->changePassword($this->getUser()->id, $data['password'], true, $data['currentPassword']);
|
||||
}
|
||||
|
||||
public function actionChangePasswordByRequest($params, $data, $request)
|
||||
public function postActionChangePasswordByRequest($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['requestId']) || empty($data['password'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -89,23 +83,27 @@ class User extends \Espo\Core\Controllers\Record
|
||||
|
||||
$this->getEntityManager()->removeEntity($p);
|
||||
|
||||
return $this->getService('User')->changePassword($userId, $data['password']);
|
||||
if ($this->getService('User')->changePassword($userId, $data['password'])) {
|
||||
return array(
|
||||
'url' => $p->get('url')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionPasswordChangeRequest($params, $data, $request)
|
||||
public function postActionPasswordChangeRequest($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (empty($data['userName']) || empty($data['emailAddress'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$userName = $data['userName'];
|
||||
$emailAddress = $data['emailAddress'];
|
||||
$url = null;
|
||||
if (!empty($data['url'])) {
|
||||
$url = $data['url'];
|
||||
}
|
||||
|
||||
return $this->getService('User')->passwordChangeRequest($userName, $emailAddress);
|
||||
return $this->getService('User')->passwordChangeRequest($userName, $emailAddress, $url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
"hard": "hard",
|
||||
"soft": "soft",
|
||||
"Unsubscribe": "Unsubscribe",
|
||||
"Mass Emails": "Mass Emails"
|
||||
"Mass Emails": "Mass Emails",
|
||||
"Email Templates": "Email Templates"
|
||||
},
|
||||
"presetFilters": {
|
||||
"active": "Active"
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
"link": "#MassEmail",
|
||||
"acl": "read",
|
||||
"aclScope": "MassEmail"
|
||||
},
|
||||
{
|
||||
"label": "Email Templates",
|
||||
"link": "#EmailTemplate",
|
||||
"acl": "read",
|
||||
"aclScope": "EmailTemplate"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"emailAddressCantBeEmpty": "Email Address can not be empty",
|
||||
"userNameEmailAddressNotFound": "Username/Email Address not found",
|
||||
"forbidden": "Forbidden, please try later",
|
||||
"uniqueLinkHasBeenSent": "The unique link has been sent to the specified email address.",
|
||||
"uniqueLinkHasBeenSent": "The unique URL has been sent to the specified email address.",
|
||||
"passwordChangedByRequest": "Password has been changed."
|
||||
},
|
||||
"boolFilters": {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
"readOnly": true,
|
||||
"index": true
|
||||
},
|
||||
"url": {
|
||||
"type": "url"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
|
||||
@@ -127,7 +127,7 @@ class User extends Record
|
||||
return true;
|
||||
}
|
||||
|
||||
public function passwordChangeRequest($userName, $emailAddress)
|
||||
public function passwordChangeRequest($userName, $emailAddress, $url = null)
|
||||
{
|
||||
$user = $this->getEntityManager()->getRepository('User')->where(array(
|
||||
'userName' => $userName,
|
||||
@@ -156,7 +156,8 @@ class User extends Record
|
||||
$passwordChangeRequest = $this->getEntityManager()->getEntity('PasswordChangeRequest');
|
||||
$passwordChangeRequest->set(array(
|
||||
'userId' => $userId,
|
||||
'requestId' => $requestId
|
||||
'requestId' => $requestId,
|
||||
'url' => $url
|
||||
));
|
||||
|
||||
$this->sendChangePasswordLink($requestId, $emailAddress);
|
||||
|
||||
@@ -35,7 +35,7 @@ Espo.define('controllers/password-change-request', 'controller', function (Dep)
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
this.entire('User.PasswordChangeRequest', {
|
||||
this.entire('views/user/password-change-request', {
|
||||
requestId: id
|
||||
}, function (view) {
|
||||
view.render();
|
||||
|
||||
@@ -35,7 +35,7 @@ Espo.define('views/login', 'view', function (Dep) {
|
||||
views: {
|
||||
footer: {
|
||||
el: 'body > footer',
|
||||
view: 'Site.Footer'
|
||||
view: 'views/site/footer'
|
||||
},
|
||||
},
|
||||
|
||||
@@ -131,7 +131,8 @@ Espo.define('views/login', 'view', function (Dep) {
|
||||
|
||||
showPasswordChangeRequest: function () {
|
||||
this.notify('Please wait...');
|
||||
this.createView('passwordChangeRequest', 'Modals.PasswordChangeRequest', {
|
||||
this.createView('passwordChangeRequest', 'views/modals/password-change-request', {
|
||||
url: window.location.href
|
||||
}, function (view) {
|
||||
view.render();
|
||||
view.notify(false);
|
||||
|
||||
@@ -95,7 +95,7 @@ Espo.define('views/modals/change-password', 'views/modal', function (Dep) {
|
||||
},
|
||||
|
||||
|
||||
actionChangePassword: function () {
|
||||
actionChange: function () {
|
||||
this.getView('currentPassword').fetchToModel();
|
||||
this.getView('password').fetchToModel();
|
||||
this.getView('passwordConfirm').fetchToModel();
|
||||
|
||||
@@ -40,10 +40,7 @@ Espo.define('views/modals/password-change-request', 'views/modal', function (Dep
|
||||
{
|
||||
name: 'submit',
|
||||
label: 'Submit',
|
||||
style: 'danger',
|
||||
onClick: function (dialog) {
|
||||
this.submit();
|
||||
}.bind(this)
|
||||
style: 'danger'
|
||||
},
|
||||
{
|
||||
name: 'cancel',
|
||||
@@ -117,7 +114,8 @@ Espo.define('views/modals/password-change-request', 'views/modal', function (Dep
|
||||
type: 'POST',
|
||||
data: JSON.stringify({
|
||||
userName: userName,
|
||||
emailAddress: emailAddress
|
||||
emailAddress: emailAddress,
|
||||
url: this.options.url
|
||||
}),
|
||||
error: function (xhr) {
|
||||
if (xhr.status == 404) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views./user/password-change-request', 'view', function (Dep) {
|
||||
Espo.define('views/user/password-change-request', 'view', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -102,11 +102,13 @@ Espo.define('views./user/password-change-request', 'view', function (Dep) {
|
||||
error: function () {
|
||||
this.$el.find('.btn-submit').removeClass('disabled');
|
||||
}.bind(this)
|
||||
}).done(function () {
|
||||
}).done(function (data) {
|
||||
this.$el.find('.password-change').remove();
|
||||
|
||||
var url = data.url || this.getConfig().get('siteUrl');
|
||||
|
||||
var msg = this.translate('passwordChangedByRequest', 'messages', 'User');
|
||||
msg += ' <a href="' + this.getConfig().get('siteUrl') + '">' + this.translate('Login', 'labels', 'User') + '</a>.';
|
||||
msg += ' <a href="' + url + '">' + this.translate('Login', 'labels', 'User') + '</a>.';
|
||||
|
||||
this.$el.find('.msg-box').removeClass('hidden').html('<span class="text-success">' + msg + '</span>');
|
||||
}.bind(this));
|
||||
|
||||
Reference in New Issue
Block a user