Class: PasswordCreationService
Service with functions related to password creation to check if password is strong, and the number of attempts user can do to update a password
Implements
Constructors
new PasswordCreationService()
new PasswordCreationService(
settings
,passwordStorageService
,passwordValidationService
,passwordStrengthService
):PasswordCreationService
Constructor
Parameters
Parameter | Type |
---|---|
settings | PasswordSettingsInterface |
passwordStorageService | PasswordStorageService |
passwordValidationService | PasswordValidationService |
passwordStrengthService | PasswordStrengthService |
Returns
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:26 (opens in a new tab)
Properties
Property | Modifier | Type |
---|---|---|
passwordStorageService | readonly | PasswordStorageService |
passwordStrengthService | readonly | PasswordStrengthService |
passwordValidationService | readonly | PasswordValidationService |
settings | readonly | PasswordSettingsInterface |
Methods
checkAttempt()
checkAttempt(
numOfAttempts
):boolean
Check if number of current attempt is allowed based on the amount of attempts left if the number of attempts left is greater then
Parameters
Parameter | Type | Default value |
---|---|---|
numOfAttempts | number | 0 |
Returns
boolean
Number of attempts user has to try
Implementation of
PasswordCreationServiceInterface
.checkAttempt
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:155 (opens in a new tab)
checkAttemptLeft()
checkAttemptLeft(
numOfAttempts
):number
Check number of attempts of using password
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
numOfAttempts | number | 0 | number of attempts |
Returns
number
Implementation of
PasswordCreationServiceInterface
.checkAttemptLeft
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:164 (opens in a new tab)
createObject()
Create password for an object.
Param
An object containing the new password to hash.
Param
Password create options.
createObject(object, options)
createObject<
T
>(object
,options
?):Promise
<Omit
<T
,"password"
> &PasswordStorageInterface
>
Create password for an object.
Type Parameters
Type Parameter |
---|
T extends PasswordPlainInterface |
Parameters
Parameter | Type | Description |
---|---|---|
object | T | An object containing the new password to hash. |
options ? | PasswordCreateObjectOptionsInterface | Password create options. |
Returns
Promise
<Omit
<T
, "password"
> & PasswordStorageInterface
>
A new object with the password hashed, with salt added.
Implementation of
PasswordCreationServiceInterface
.createObject
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:41 (opens in a new tab)
createObject(object, options)
createObject<
T
>(object
,options
?):Promise
<Omit
<T
,"password"
> |Omit
<T
,"password"
> &Partial
<PasswordStorageInterface
>>
Create password for an object.
Type Parameters
Type Parameter |
---|
T extends Partial <PasswordPlainInterface > |
Parameters
Parameter | Type | Description |
---|---|---|
object | T | An object containing the new password to hash. |
options ? | PasswordCreateObjectOptionsInterface | Password create options. |
Returns
Promise
<Omit
<T
, "password"
> | Omit
<T
, "password"
> & Partial
<PasswordStorageInterface
>>
A new object with the password hashed, with salt added.
Implementation of
PasswordCreationServiceInterface.createObject
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:53 (opens in a new tab)
validateCurrent()
validateCurrent(
options
):Promise
<boolean
>
Validate the current password for the targeted object.
Parameters
Parameter | Type | Description |
---|---|---|
options | Partial <PasswordCurrentPasswordInterface > | Validate current options. |
Returns
Promise
<boolean
>
boolean
Implementation of
PasswordCreationServiceInterface
.validateCurrent
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:89 (opens in a new tab)
validateHistory()
validateHistory(
options
):Promise
<boolean
>
Validate the array of password stores to check for previous usage.
Parameters
Parameter | Type | Description |
---|---|---|
options | Partial <PasswordHistoryPasswordInterface > | Validate history options. |
Returns
Promise
<boolean
>
boolean Returns true if password has NOT been used withing configured range.
Implementation of
PasswordCreationServiceInterface
.validateHistory
Defined in
packages/nestjs-password/src/services/password-creation.service.ts:114 (opens in a new tab)