mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
d8ff186303
Client and server now have their own tsconfig so that the transpilation is only done on the part that is being modified. It also allows faster transpilation since tests are now excluded from tsconfig. They are compiled by ts-node during unit tests execution.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import BluebirdPromise = require("bluebird");
|
|
import exceptions = require("../Exceptions");
|
|
import ldapjs = require("ldapjs");
|
|
import { Client } from "./Client";
|
|
|
|
import { IPasswordUpdater } from "./IPasswordUpdater";
|
|
import { LdapConfiguration } from "../configuration/Configuration";
|
|
import { IClientFactory } from "./IClientFactory";
|
|
|
|
|
|
export class PasswordUpdater implements IPasswordUpdater {
|
|
private options: LdapConfiguration;
|
|
private clientFactory: IClientFactory;
|
|
|
|
constructor(options: LdapConfiguration, clientFactory: IClientFactory) {
|
|
this.options = options;
|
|
this.clientFactory = clientFactory;
|
|
}
|
|
|
|
updatePassword(username: string, newPassword: string): BluebirdPromise<void> {
|
|
const adminClient = this.clientFactory.create(this.options.user, this.options.password);
|
|
|
|
return adminClient.open()
|
|
.then(function () {
|
|
return adminClient.modifyPassword(username, newPassword);
|
|
})
|
|
.then(function () {
|
|
return adminClient.close();
|
|
})
|
|
.error(function (err: Error) {
|
|
return BluebirdPromise.reject(new exceptions.LdapError("Failed during password update: " + err.message));
|
|
});
|
|
}
|
|
}
|