talawa icon indicating copy to clipboard operation
talawa copied to clipboard

[Bug report] Inconsistencies in Password RegEx

Open M-A-D-A-R-A opened this issue 2 years ago • 19 comments

Describe the bug when I'm signing myself for he app it says invalid password but doesn't say why, i looked in code there's a regex pattern it should follow. It will be helpful for user if shows u what's wrong with password for eg :- If i wrote my password as "Hello@123" Which is wrong it shouldn't have uppercase letter, and that it should show to the user. Currently it's just showing INVALID PASSWORD.

Expected behavior It should show user what's the issue in the password.

Actual behavior Right now its just showing "Invalid Password"

Can You assign it to me? Thanks

M-A-D-A-R-A avatar Dec 04 '21 18:12 M-A-D-A-R-A

Congratulations on making your first Issue! :confetti_ball: If you haven't already, check out our Contributing Guidelines and Issue Reporting Guidelines to ensure that you are following our guidelines for contributing and making issues.

github-actions[bot] avatar Dec 04 '21 18:12 github-actions[bot]

@M-A-D-A-R-A What was the password you used and what is the password the code expects? It's not clear from your issue.

palisadoes avatar Dec 04 '21 18:12 palisadoes

First i tried with "N1234567" it said Invalid password , then i tried with "Nishant" it said "Invalid password " again, now for "ASDFGH" it accepted this password.

M-A-D-A-R-A avatar Dec 04 '21 19:12 M-A-D-A-R-A

We should only allowing passwords with:

  • A combination of upper and lower case letters;
  • Special characters; and
  • Numbers?

This should be stated in the change password screen and enforced.

palisadoes avatar Dec 04 '21 19:12 palisadoes

The Written Regex right now is:-

r'^(?=.?[A-Z])(?=.?[a-z])(?=.?[0-9])(?=.?[!@#$&*~]).{8,}$

means r'^ (?=.[A-Z]) // should contain at least one upper case (?=.[a-z]) // should contain at least one lower case (?=.?[0-9]) // should contain at least one digit (?=.?[!@#$&*~]) // should contain at least one Special character .{8,} // Must be at least 8 characters in length
$

So at the end all it shows is "invalid password" not show Why the password is invalid.

M-A-D-A-R-A avatar Dec 04 '21 19:12 M-A-D-A-R-A

Is the regex in the change password screen or the login screen? The verification of the regex should only be done when the password is changed. @CyberWake, @sumitra19jha, @rutvik11062000, what could be the issue here?

palisadoes avatar Dec 04 '21 19:12 palisadoes

The verification is done after the change. But yes, password validation throws an "Invalid Password" error message. It should be changed into, "Password must consist of at least one upper case letter and symbol"

sumitra19jha avatar Dec 04 '21 20:12 sumitra19jha

Earlier we tend to use a package for the same this as @M-A-D-A-R-A stated to show at what parameters the password is not validating. After the migration process, we found the package to be nonnull safe plus it was having issues when writing some of the test cases. As far as the concern showed we may need to update the validation statement by checking on what grounds the regex failed.

CyberWake avatar Dec 05 '21 06:12 CyberWake

@M-A-D-A-R-A if you wish to work on this one please feel free to ping in slack. We'll get this assigned to you.

CyberWake avatar Dec 05 '21 06:12 CyberWake

I would like to work on this issue. @CyberWake

AvneetSingh2001 avatar Dec 08 '21 19:12 AvneetSingh2001

@M-A-D-A-R-A, I assigned this to @AvneetSingh2001 as you didn't respond to @CyberWake

palisadoes avatar Dec 08 '21 19:12 palisadoes

@M-A-D-A-R-A, I assigned this to @AvneetSingh2001 as you didn't respond to @CyberWake

I already mentioned in the issue that can u assign it to me, also i told sumitra that I'm working on it but it's cool already assigned it to @AvneetSingh2001, no issues. Thanks

M-A-D-A-R-A avatar Dec 08 '21 20:12 M-A-D-A-R-A

@M-A-D-A-R-A I didn't see your request in the original comment. I'll reassign it. I don't want to have your time wasted.

palisadoes avatar Dec 08 '21 20:12 palisadoes

So Im trying to define a bool variable for checking every case.

final bool hasUppercase = password.contains(RegExp(r'^(?=.[A-Z])+$')); final bool hasDigits = password.contains( RegExp(r'^-?[0-9]+$')); final bool hasLowercase = password.contains(RegExp(r'^(?=.[a-z])+$')); final bool hasSpecialCharacters = password.contains( RegExp(r'[!@#$%^&*(),.?":{}|<>]'));

but the bool is not returning any values?

I tried doing the same things as it was done for space regex. But the issue was still the same.

I don't know how to proceed further, any help will be appreciated. thanks.

M-A-D-A-R-A avatar Dec 10 '21 17:12 M-A-D-A-R-A

@CyberWake @sumitra19jha Please take a look.

palisadoes avatar Dec 10 '21 17:12 palisadoes

@CyberWake @sumitra19jha Please take a look.

It will be helpful if you could give a hint so that i can proceed further.

@sumitra19jha @CyberWake

M-A-D-A-R-A avatar Dec 12 '21 13:12 M-A-D-A-R-A

So Im trying to define a bool variable for checking every case.

final bool hasUppercase = password.contains(RegExp(r'^(?=.[A-Z])+$')); final bool hasDigits = password.contains( RegExp(r'^-?[0-9]+$')); final bool hasLowercase = password.contains(RegExp(r'^(?=.[a-z])+$')); final bool hasSpecialCharacters = password.contains( RegExp(r'[!@#$%^&*(),.?":{}|<>]'));

but the bool is not returning any values?

I tried doing the same things as it was done for space regex. But the issue was still the same.

I don't know how to proceed further, any help will be appreciated. thanks.

Please share the output of the error log file. What error is your console throwing?

sumitra19jha avatar Dec 12 '21 15:12 sumitra19jha

So Im trying to define a bool variable for checking every case. final bool hasUppercase = password.contains(RegExp(r'^(?=.[A-Z])+$')); final bool hasDigits = password.contains( RegExp(r'^-?[0-9]+$')); final bool hasLowercase = password.contains(RegExp(r'^(?=.[a-z])+$')); final bool hasSpecialCharacters = password.contains( RegExp(r'[!@#$%^&*(),.?":{}|<>]')); but the bool is not returning any values? I tried doing the same things as it was done for space regex. But the issue was still the same. I don't know how to proceed further, any help will be appreciated. thanks.

Please share the output of the error log file. What error is your console throwing?

For the Following bools I'm getting these values. image I tried other Regex too but the values are same.

M-A-D-A-R-A avatar Dec 12 '21 17:12 M-A-D-A-R-A

Is this issue fixed ? If not, I'd like to work on it. Otherwise please close it.

literalEval avatar Dec 23 '21 12:12 literalEval