Skip to content

Fix: Add null check before accessing FirebaseAuth.currentUser.uid#296

Open
prjanitor wants to merge 1 commit intoTSEC-MAD-Club:mainfrom
prjanitor:prjanitor/47fb7b80a81885225cc010005daa1870b5dbdf95
Open

Fix: Add null check before accessing FirebaseAuth.currentUser.uid#296
prjanitor wants to merge 1 commit intoTSEC-MAD-Club:mainfrom
prjanitor:prjanitor/47fb7b80a81885225cc010005daa1870b5dbdf95

Conversation

@prjanitor
Copy link
Copy Markdown

Bug Fix: Missing null check before accessing currentUser.uid

Problem

In login_screen.dart, the code accesses FirebaseAuth.instance.currentUser!.uid without checking if currentUser is null. This can cause a null pointer exception if the user is not authenticated or the session has expired.

Solution

Added a null check for FirebaseAuth.instance.currentUser before accessing the .uid property. The setupFCMNotifications method is now only called when both userModel and currentUser are valid.

Changes

  • Store FirebaseAuth.instance.currentUser in a variable
  • Add null check before accessing .uid
  • Only call setupFCMNotifications when currentUser is not null

Testing

This fix prevents crashes when:

  • User session expires
  • Authentication state is not properly initialized
  • Network issues cause auth state to be null

This PR was generated by PRJanitor — an automated tool that finds and fixes small bugs in open-source projects.

We respect your contribution guidelines — if your project doesn't accept bot PRs, we won't send more. You can also add a .github/prjanitor.yml file with enabled: false to opt out explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant