Skip to content

Conversation

@MapleSyyrup
Copy link
Owner

  • 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

Problem:
Even if the user is already authenticated, ProductOverviewScreen still does not show after clicking the login button.

image

- 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
@MapleSyyrup MapleSyyrup requested a review from Nei1eveN March 15, 2021 10:06
@MapleSyyrup MapleSyyrup linked an issue Mar 15, 2021 that may be closed by this pull request
- Favorited items will be specific for each user
- A log out button is added
Copy link
Contributor

@Nei1eveN Nei1eveN left a 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 {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +64 to +81
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();
}
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

showFavs == true

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.

Adding authentication for users

3 participants