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

Improve Error Message for Invalid Password #177

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions backend/src/zelthy/apps/shared/platformauth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ def create_user(
)
else:
if not cls.validate_password(password):
message = "Invalid password. Password must follow rules xyz"
message = """Invalid Password

The password provided does not meet the required criteria. Please ensure that your password follows these rules:
1. Must contain at least 8 characters.
2. Must contain at least one uppercase letter.
3. Must contain at least one lowercase letter.
4. Must contain at least one number.
5. Must contain at least one special character."""
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AjaySDwivedi1 We don't need to remove the else block here, we can just update the message string

platform_user = cls.objects.create(
name=name,
Expand Down Expand Up @@ -154,7 +161,14 @@ def update_user(self, data):
password = data.get("password")
if password:
if not self.validate_password(password):
message = "Invalid password. Password must follow rules xyz"
message = """Invalid Password

The password provided does not meet the required criteria. Please ensure that your password follows these rules:
1. Must contain at least 8 characters.
2. Must contain at least one uppercase letter.
3. Must contain at least one lowercase letter.
4. Must contain at least one number.
5. Must contain at least one special character."""
return {"success": False, "message": message}

self.set_password(password)
Expand Down