-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPasswordChangeService.ts
42 lines (37 loc) · 1.23 KB
/
PasswordChangeService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { makeDefaultOptions } from '../options';
import passwordChange from '../methods/password-change';
import { AuthenticationManagementBase } from './AuthenticationManagementBase';
import type {
SanitizedUser,
DataPasswordChange,
PasswordChangeOptions,
PasswordChangeServiceOptions
} from '../types';
import type { Application, Params } from '@feathersjs/feathers';
export class PasswordChangeService
extends AuthenticationManagementBase<DataPasswordChange, SanitizedUser, PasswordChangeServiceOptions> {
constructor (app: Application, options?: Partial<PasswordChangeOptions>) {
super(app);
const defaultOptions = makeDefaultOptions([
'service',
'notifier',
'identifyUserProps',
'sanitizeUserForClient',
'passwordField',
'skipPasswordHash',
'passParams'
]);
this.options = Object.assign(defaultOptions, options);
}
async _create (data: DataPasswordChange, params?: Params): Promise<SanitizedUser> {
const passedParams = this.options.passParams && await this.options.passParams(params);
return await passwordChange(
this.optionsWithApp,
data.user,
data.oldPassword,
data.password,
data.notifierOptions,
passedParams
);
}
}