-
Notifications
You must be signed in to change notification settings - Fork 0
Adding authentication for users #46
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
base: main
Are you sure you want to change the base?
Conversation
- For the first time user, the user will be asked to sign up - For the exiting users after their email is authenticated, they will be able to login anytime
- Favorited items will be specific for each user - A log out button is added
Nei1eveN
left a comment
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.
Please document files
| String? _userId; | ||
| Timer? _authTimer; | ||
|
|
||
| bool get isAuth { |
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.
please put short description
| return token != null; | ||
| } | ||
|
|
||
| String? get token { |
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.
document this method
| return null; | ||
| } | ||
|
|
||
| String? get userId { |
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.
document
| return _userId; | ||
| } | ||
|
|
||
| Future<void> _authenticate(String? email, String? password, String urlSegment) async { |
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.
same here
| Future<void> signUp(String? email, String? password) async { | ||
| return _authenticate(email, password, 'signUp'); | ||
| } | ||
|
|
||
| Future<void> login(String? email, String? password) async { | ||
| return _authenticate(email, password, 'signInWithPassword'); | ||
| } | ||
|
|
||
| void logout() { | ||
| _token = null; | ||
| _userId = null; | ||
| _expiryDate = null; | ||
| if (_authTimer != null) { | ||
| _authTimer?.cancel(); | ||
| _authTimer = null; | ||
| } | ||
| notifyListeners(); | ||
| } |
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.
please document all methods
| ///Class for arguments that the navigator needs | ||
| class EditProductArguments { | ||
| final String productId; | ||
| final String? productId; |
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.
may I ask why this productId is nullable?
| static const routeName = '/edit-product'; | ||
|
|
||
| final EditProductArguments editProductarguments; | ||
| final EditProductArguments? editProductarguments; |
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.
Document methods and constructors
| String validatorTitle(String value) { | ||
| return value.isEmpty ? 'Error description example' : null; | ||
| String? validatorTitle(String? value) { | ||
| return value!.isEmpty ? 'Error description example' : null; |
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.
replace this with nullable approach:
value?.isEmpty == true
| class ProductDetailScreen extends StatelessWidget { | ||
| static const routeName = '/product-detail'; | ||
| final String productDetailArgs; | ||
| final String? productDetailArgs; |
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.
may I know why this is nullable? Is there a chance that this can be optional?
| Widget build(BuildContext context) { | ||
| final productsData = Provider.of<ProductsProvider>(context); | ||
| final products = showFavs ? productsData.favoriteItems : productsData.items; | ||
| final products = showFavs! ? productsData.favoriteItems : productsData.items; |
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.
showFavs == true
able to login anytime
Problem:
Even if the user is already authenticated,
ProductOverviewScreenstill does not show after clicking the login button.