-
Notifications
You must be signed in to change notification settings - Fork 0
Fix authentication #17
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
1b8616a
ca36a5c
9a2b1e9
bbbff11
ad65ef2
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 |
---|---|---|
|
@@ -43,8 +43,17 @@ Future<Response> onRequest(RequestContext context) async { | |
); | ||
} | ||
|
||
// Check for the optional dashboard login flag. Default to false if not present. | ||
final isDashboardLogin = (body['isDashboardLogin'] as bool?) ?? false; | ||
// Check for the optional dashboard login flag. This handles both boolean | ||
// `true` and string `"true"` values to prevent type cast errors. | ||
// It defaults to `false` if the key is missing or the value is not | ||
// recognized as true. | ||
final isDashboardLoginRaw = body['isDashboardLogin']; | ||
var isDashboardLogin = false; | ||
if (isDashboardLoginRaw is bool) { | ||
isDashboardLogin = isDashboardLoginRaw; | ||
} else if (isDashboardLoginRaw is String) { | ||
isDashboardLogin = isDashboardLoginRaw.toLowerCase() == 'true'; | ||
} | ||
Comment on lines
+50
to
+56
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. This logic is much more robust than the previous implementation. For improved conciseness and to leverage modern Dart features, you could consider using a
|
||
|
||
// Basic email format check (more robust validation can be added) | ||
// Using a slightly more common regex pattern | ||
|
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.
This is a great security check. However, email addresses are typically treated as case-insensitive. This comparison is case-sensitive. If the user lookup in
_findUserByEmail
is or becomes case-insensitive, a user logging in with[email protected]
might be found in the database as[email protected]
, causing this check to fail incorrectly. To make this more robust, consider performing a case-insensitive comparison.