Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading spaces when creating users lead to bad data in system #707

Closed
Tracked by #1557 ...
vinayvenu opened this issue Apr 2, 2024 · 16 comments · Fixed by #725
Closed
Tracked by #1557 ...

Leading spaces when creating users lead to bad data in system #707

vinayvenu opened this issue Apr 2, 2024 · 16 comments · Fixed by #725

Comments

@vinayvenu
Copy link
Member

Users with usernames starting with spaces are created in

POST /user
{
  "operatingIndividualScope": "ByCatchment",
  "username": " testvinay1@gdgsgom",
  "ignored": " testvinay1",
  "name": "test",
  "email": "tas@asd.com",
  "phoneNumber": "+919693939393",
  "catchmentId": 21002
}

Response

{
  "message": "2 validation errors detected: Value at 'temporaryPassword' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[\\S]+.*[\\S]+$; Value at 'username' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+ (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: 7addf14f-e99c-4d77-8c2c-2278e1589436)"
}

Problem
The user is not created in Cognito, but is created on the database. The next time this user is created, the app mentions that the user already exists

Acceptance criteria

  • Usernames and emails must be trimmed before validation or adding to the system
  • Database changes should be reverted in case there is an error adding the user to the ID system
  • These validations should work in csv uploads as well, where we have the same problem
@Dashlet26
Copy link

Here is my solution regarding this problem ,
If we have to resolve the issue then

  1. we must ensure that username value does not start with space meets regular expression pattern Cognito
  2. Modify request to provide a valid username that meets criteria by Cognito .

@vinayvenu
Copy link
Member Author

@Dashlet26 the solution is outlined in the Acceptance criteria section.

@MiirzaBaig
Copy link

@vinayvenu Could you assign me this issue?

@vinayvenu
Copy link
Member Author

@MiirzaBaig there is no assignment. You can work on it, raise a PR when you are ready.

ombhardwajj added a commit to ombhardwajj/avni-server that referenced this issue Apr 25, 2024
@mahalakshme mahalakshme moved this from New Issues to Code Review Ready in Avni Product Apr 29, 2024
@petmongrels petmongrels moved this from Code Review Ready to In Code Review in Avni Product Apr 29, 2024
@petmongrels
Copy link
Contributor

  1. Please move this method inside UserContract class. It is dealing with only the state of user contract. ombhardwajj@f5d8cb7#diff-4c6e9031b146d5df5d1f3276fa07838ea5e1d0158cb3aee6348f91b656b888baR77
  2. The file uploaded by the user should not be modified and stored in S3. Since it is the source file, it should be uploaded as it is. The removal of spaces should be handled in the code when reading the file.

@petmongrels petmongrels moved this from In Code Review to Code Review with Comments in Avni Product Apr 29, 2024
@AchalaBelokar AchalaBelokar moved this from Code Review with Comments to QA Ready in Avni Product May 1, 2024
@mahalakshme
Copy link
Contributor

@AchalaBelokar why have you moved the card to QA Ready? moving back for now since looks like the comments are not fixed.

@mahalakshme mahalakshme moved this from QA Ready to Code Review with Comments in Avni Product May 2, 2024
@ombhardwajj
Copy link
Contributor

ombhardwajj commented May 2, 2024

Hey @petmongrels and @mahalakshme,

Apologies for the delay in addressing your comment; I was caught up with exams this week. I've made the necessary adjustments based on your feedback. Specifically, I've reverted the changes made to the S3Service, IdpService, and Factory files back to their original state. Additionally, I've modified the UserContract.java files to handle trimming.

Could you please review the changes and let me know if they meet your expectations? If any further adjustments are needed, please point them out.

master...ombhardwajj:avni-server:spacefix

@petmongrels petmongrels moved this from Code Review with Comments to Code Review Ready in Avni Product May 3, 2024
@petmongrels petmongrels moved this from Code Review Ready to In Code Review in Avni Product May 3, 2024
@petmongrels
Copy link
Contributor

looks good. please send a pull request.

@petmongrels petmongrels moved this from In Code Review to Code Review with Comments in Avni Product May 3, 2024
vinayvenu added a commit that referenced this issue May 6, 2024
#707 | Leading spaces when creating users are now trimmed!
@github-project-automation github-project-automation bot moved this from Code Review with Comments to Done in Avni Product May 6, 2024
@vinayvenu vinayvenu moved this from Done to QA Ready in Avni Product May 6, 2024
@vinayvenu
Copy link
Member Author

Verification required for

  1. POST request to create/update user
  2. csv upload of UsersAndCatchments csv

@vinayvenu vinayvenu reopened this May 6, 2024
@vinayvenu vinayvenu moved this from Triaged to QA Ready in Avni Product May 14, 2024
@justAbhinav
Copy link

@vinayvenu reading from this issue timeline i have understood that the issue has been solved, so why is this re opened, and in that case what issues remain?

@vinayvenu
Copy link
Member Author

vinayvenu commented May 24, 2024

@justAbhinav it was reopened because sufficient QA was not done on it yet. Will be closed once the QA says ok

@AchalaBelokar AchalaBelokar moved this from QA Ready to In QA in Avni Product Jul 31, 2024
@AchalaBelokar AchalaBelokar moved this from In QA to QA Ready in Avni Product Jul 31, 2024
@Dinesh2019 Dinesh2019 moved this from QA Ready to In QA in Avni Product Aug 5, 2024
@Dinesh2019 Dinesh2019 self-assigned this Aug 5, 2024
@Dinesh2019
Copy link

We can able to create the user with the space it is displaying the error but the user is created.And i suggest we have the validation in each field

Refer the video :

Click here to watch video

@Dinesh2019 Dinesh2019 moved this from In QA to QA Failed in Avni Product Aug 6, 2024
@mahalakshme
Copy link
Contributor

@ombhardwajj would you like to fix the above QA comment

@ombhardwajj
Copy link
Contributor

ombhardwajj commented Aug 13, 2024

@mahalakshme As I told in the other comment as well, I can only take this once I am done with the metabase issue!

@himeshr himeshr self-assigned this Aug 14, 2024
@himeshr himeshr moved this from QA Failed to In Progress in Avni Product Aug 14, 2024
himeshr added a commit to avniproject/avni-webapp that referenced this issue Aug 14, 2024
himeshr added a commit to avniproject/avni-webapp that referenced this issue Aug 14, 2024
@himeshr himeshr moved this from In Progress to QA Ready in Avni Product Aug 14, 2024
himeshr added a commit to avniproject/avni-webapp that referenced this issue Aug 14, 2024
@himeshr himeshr moved this from QA Ready to Code Review Ready in Avni Product Aug 14, 2024
@himeshr
Copy link
Contributor

himeshr commented Aug 16, 2024

Validations for whitespaces during user create/edit.
Screenshot 2024-08-16 at 11 06 38 AM

@1t5j0y 1t5j0y moved this from In Code Review to QA Ready in Avni Product Aug 19, 2024
@AchalaBelokar
Copy link

  • when I am try to edit the user it is giving me error something is getting wrong
Screen.Recording.2024-08-22.at.10.57.56.PM.mov

@AchalaBelokar AchalaBelokar moved this from In QA to QA Failed in Avni Product Aug 22, 2024
@himeshr himeshr moved this from QA Failed to In Progress in Avni Product Aug 23, 2024
himeshr added a commit to avniproject/avni-webapp that referenced this issue Aug 23, 2024
@himeshr himeshr moved this from In Progress to QA Ready in Avni Product Aug 23, 2024
@Dinesh2019 Dinesh2019 moved this from In QA to Done in Avni Product Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

10 participants