#1 2023-09-11 06:30:36

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

TSynValidatePassWord on which property?

On which property of the TAuthUser class can we apply the TSynValidatePassWord validator? The following:

TAuthUser.AddFilterOrValidate('PasswordPlain', TSynValidatePassWord.Create())

raises an exception:

Project InsPumpSrv.exe raised exception class EOrmException with message 'TOrmPropInfoList.IndexByNameOrExcept(PasswordPlain): unkwnown field in TAuthUser'.

Offline

#2 2023-09-11 07:20:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: TSynValidatePassWord on which property?

Check the error message again.
TAuthUser has no PasswordPlain published property, I guess.

You can't add a filter on a property with getter and setter.

Online

#3 2023-09-11 08:59:13

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Re: TSynValidatePassWord on which property?

ab wrote:

TAuthUser has no PasswordPlain published property

That was exactly the meaning of my message @ab. smile The TAuthUser class has no published property with the plain password and I presume that it is meaningless to apply this validator on the PasswordHasHexa property. So, on which property can we apply this password validator? Can we create a dummy, DTO like class (not a TOrm descendant, or if it is mandatory to be a TOrm child to not include it in the model creation, so to avoid having this table in our DB), with a plain password as published property, then apply this validator on this property and if it succeeds to use this value to assign it to the PasswordPlain property of the TAuthUser class instance?

Not a quite elegant solution...

Last edited by damiand (2023-09-11 09:09:32)

Offline

#4 2023-09-11 11:00:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: TSynValidatePassWord on which property?

You can just create a TSynValidatePassWord instance with the appropriate password strength restrictions, then call TSynValidatePassWord.Process() with the text values.
No need to create an transient class.

Online

Board footer

Powered by FluxBB