polina-c / flutter-auth-ui

flutter-auth-ui is an authentication library for flutter web applications. It uses Firebase auth as security as a service (SECaaS) provider. It implements UI to register user, validate email, sign in, sign out, restore password, access firestore..
https://flatter-auth-ui-demo1.codemagic.app/#/
Apache License 2.0
57 stars 18 forks source link

Replaced crypted-preferences... #13

Closed jason-dgio closed 4 years ago

jason-dgio commented 5 years ago

…with the official shared-preferences dependency

jason-dgio commented 5 years ago

Sure, that shouldn't have been there, I'll amend

Sent from ProtonMail mobile

-------- Original Message -------- On 3 Nov 2019, 20:39, Polina Cherkasova wrote:

@polina-c commented on this pull request.


In lib/src/FauiLocalStorage.dart:

  • FauiUser user = FauiUser.fromJson(jsonDecode(v));
  • if (user == null || user.refreshToken == null) {
  • print("sso: no refresh token found");
  • return;
  • }
  • user = await FbConnector.refreshToken(user: user, apiKey: apiKey);
  • _storeLocally(_LocalKey, jsonEncode(user));
  • FauiAuthState.user = user;
  • print("sso: succeeded silent sign-in");
  • return;
  • FauiUser user = FauiUser.fromJson(jsonDecode(v));
  • if (user == null || user.refreshToken == null) {
  • print("sso: no refresh token found");
  • return;

It seems second print will never happen.


In lib/src/FauiLocalStorage.dart:

 print("sso: started silent sign-in");

try {

  • await _initialize();
  • FauiUtil.throwIfNullOrEmpty(value: apiKey, name: "apiKey");
  • String v = _getLocalValue(_LocalKey);
  • if (v == null || v == "null") {
  • print("sso: no user stored");
  • return;
  • }
  • await _getLocalValue(_LocalKey).then((String v) async {

If you use the keyword 'await', you do not need 'then'. Next statement will wait for this statement to finish. There are two styles to manage asynchrony: (1) with 'then' and (2, more modern) with async/await/Future. In Faui I use the second way.

See more details here: https://dart.dev/codelabs/async-await.

Can you remove 'then', please?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

polina-c commented 5 years ago

shared_preferences is a plugin. Flutter web does not support plugins yet. Holding this PR till plugin support.