change password permission
This commit is contained in:
parent
205f6b2c54
commit
aa4bfb4f51
|
@ -15,7 +15,7 @@
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
<vn-submit label="Save"></vn-submit>
|
<vn-submit label="Save"></vn-submit>
|
||||||
<vn-button label="Change password" vn-dialog="change-pass"></vn-button>
|
<vn-button ng-if="$ctrl.canChangePassword" label="Change password" vn-dialog="change-pass"></vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
|
|
|
@ -5,10 +5,23 @@ export default class Controller {
|
||||||
this.$ = $scope;
|
this.$ = $scope;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
|
this.canChangePassword = false;
|
||||||
}
|
}
|
||||||
$onChanges() {
|
$onChanges() {
|
||||||
if (this.client)
|
if (this.client) {
|
||||||
this.account = this.client.account;
|
this.account = this.client.account;
|
||||||
|
this.isCustomer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isCustomer() {
|
||||||
|
if (this.client && this.client.id) {
|
||||||
|
this.$http.get(`/client/api/Clients/${this.client.id}/getRoleCustomer`).then(res => {
|
||||||
|
this.canChangePassword = (res.data && res.data.length) ? res.data[0].isCustomer : false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.canChangePassword = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onPassOpen() {
|
onPassOpen() {
|
||||||
this.newPassword = '';
|
this.newPassword = '';
|
||||||
|
@ -16,7 +29,7 @@ export default class Controller {
|
||||||
this.$.$apply();
|
this.$.$apply();
|
||||||
}
|
}
|
||||||
onPassChange(response) {
|
onPassChange(response) {
|
||||||
if (response == 'ACCEPT')
|
if (response == 'ACCEPT' && this.canChangePassword)
|
||||||
try {
|
try {
|
||||||
if (!this.newPassword)
|
if (!this.newPassword)
|
||||||
throw new Error(`Passwords can't be empty`);
|
throw new Error(`Passwords can't be empty`);
|
||||||
|
|
Loading…
Reference in New Issue