-
Notifications
You must be signed in to change notification settings - Fork 0
Login Functionality Using Python [VALI-004] #3
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| __pycache__ | ||
| .appmodconfig |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| class LoginSystem: | ||||||
| def __init__(self): | ||||||
| self.valid_email = os.getenv("VALID_EMAIL") | ||||||
| self.valid_password = os.getenv("VALID_PASSWORD") | ||||||
| self.failed_attempts = 0 | ||||||
| self.locked = False | ||||||
|
|
||||||
| def login(self, email, password): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Boolean-Returning Function Without Prefix The
Suggested change
Reasons & GapsReasons
Gaps
|
||||||
| if self.locked: | ||||||
| return "Account is locked. Contact support." | ||||||
|
|
||||||
| if email == self.valid_email and password == self.valid_password: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security Risk: Insecure Password Comparison We're using a direct equality check (
Suggested change
Reasons & GapsReasons
Gaps
|
||||||
| self.failed_attempts = 0 | ||||||
| return "Login Successful ✅" | ||||||
|
|
||||||
| else: | ||||||
| self.failed_attempts += 1 | ||||||
|
|
||||||
| if self.failed_attempts >= 3: | ||||||
| self.locked = True | ||||||
| return "Account locked due to 3 failed attempts ❌" | ||||||
|
|
||||||
| return f"Invalid credentials. Attempts left: {3 - self.failed_attempts}" | ||||||
|
|
||||||
| # ----- Testing the function ----- | ||||||
|
|
||||||
| app = LoginSystem() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JAS - Just a suggestion The variable name
Suggested change
Reasons & GapsReasons
Gaps
|
||||||
|
|
||||||
| print(app.login("wrong@test.com", "123")) # Test case 1 | ||||||
| print(app.login("wrong@test.com", "123")) # Test case 2 | ||||||
| print(app.login("wrong@test.com", "123")) # Test case 3 (locks account) | ||||||
| print(app.login("user@test.com", "Password@123")) # Should fail because account is locked | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JAS - Just a suggestion
New Environment Variables Require Configuration
This is a great improvement for security! I see you've added
VALID_EMAILandVALID_PASSWORDas environment variables. This is an informational note to ensure these variables are configured in the CI/CD pipeline and any deployment environments (staging, production). The deployment will fail if these are not set.