Password policy check VL-WEB

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
avescovi
Posts: 25
Joined: Wed Mar 16, 2016 3:01 am
Location: Switzerland
Contact:

Password policy check VL-WEB

Post by avescovi »

Hi,

I am developing the authentication for new users.
I want to implement the classical checks:
- Min length 8 characters,
- At least 1 char [a - z]
- At least 1 char [A - Z]
- At least 1 char [0 - 9]
- At least 1 symbol [* -_ ! etc]

There is a way to check automatically these constraints or the way to run a regexp on a string?

Thanks

Andrea
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Password policy check VL-WEB

Post by Stewart Marshall »

Hi Andrea

Below is routine for validating a password along the lines of your requirement (Thanks Danny)

The basic idea is that we loop through the contents on the password on a change of value, and as soon as each requirement is met, a flag is turned on. When all flags are True, the password has passed.

Regards

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Height(400) Width(833)
Define_Com Class(#PRIM_VS.Style) Name(#Bad) Borderbottom(1) Borderbrush(#Brush1) Borderleft(1) Borderright(1) Bordertop(1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(255:19:7)

Define_Com Class(#PRIM_VS.Style) Name(#Good) Borderbottom(1) Borderbrush(#Brush2) Borderleft(1) Borderright(1) Bordertop(1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush2) Color(12:153:4)

Define_Com Class(#xDemoAlpha128.Visual) Name(#gPassword) Displayposition(1) Left(16) Parent(#COM_OWNER) Tabposition(1) Top(16) Width(313) Height(33) Editstyle(#Bad) Caption('Password') Labeltype(Caption)

Evtroutine Handling(#gPassword.Changed)

If (#Com_owner.Validate( #gPassword ))

#gPassword.EditStyle <= #Good
Else
#gPassword.EditStyle <= #Bad
Endif

Endroutine

Mthroutine Name(Validate)
Define_Map For(*Input) Class(#Prim_Alph) Name(#Password)
Define_Map For(*Result) Class(#Prim_boln) Name(#Result)

Define_Com Class(#Prim_boln) Name(#HasUpper)
Define_Com Class(#Prim_boln) Name(#HasLower)
Define_Com Class(#Prim_boln) Name(#HasDigit)
Define_Com Class(#Prim_boln) Name(#HasSymbol)

Define_Com Class(#Prim_alph) Name(#Character)

If (#Password.CurChars >= 8)

Begin_Loop Using(#Std_Num) To(#Password.CurChars)

#Character := #Password.Substring( #Std_Num 1 )

If (#Character.UpperCase.ContainsOnly( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ))
If (#Character.UpperCase = #Character)
#HasUpper := True
Endif

If (#Character.LowerCase = #Character)
#HasLower := True
Endif
Endif

If (#Character.IsNumber)
#HasDigit := True
Endif

If (#Character.Contains( "@" ) *OrIf #Character.Contains( "!" ) OrIf #Character.Contains( "?" ))
#HasSymbol := True
Endif

End_Loop

#Result := (#HasUpper And #HasLower And #HasDigit And #HasSymbol)

Endif

Endroutine

End_Com
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
avescovi
Posts: 25
Joined: Wed Mar 16, 2016 3:01 am
Location: Switzerland
Contact:

Re: Password policy check VL-WEB

Post by avescovi »

Hi Stewart,

Thank you, from your reply I see that it doesn't exist a way to directly check my constraints with a regular expression.
I will implement something based on your rountine.

have a nice day
Thank you

Andrea
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Password policy check VL-WEB

Post by Stewart Marshall »

If you REALLY want to use a regular expression, you can make a JavaScript Widget to do the job for you.

That said, I personally prefer code that reads like English, in my case, rather than something that looks like gibberish.

Code: Select all

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
avescovi
Posts: 25
Joined: Wed Mar 16, 2016 3:01 am
Location: Switzerland
Contact:

Re: Password policy check VL-WEB

Post by avescovi »

Thanks,
Have a nice day

Andrea
Post Reply