From 77e604cf50f0769792b8912fac9298df72058399 Mon Sep 17 00:00:00 2001 From: tommyxchow Date: Wed, 6 Apr 2022 03:04:11 -0400 Subject: [PATCH] Fix existing token not being validated properly --- lib/core/auth/auth_store.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/auth/auth_store.dart b/lib/core/auth/auth_store.dart index cf0db451..1e19be2e 100644 --- a/lib/core/auth/auth_store.dart +++ b/lib/core/auth/auth_store.dart @@ -64,18 +64,18 @@ abstract class _AuthBase with Store { await _storage.write(key: _defaultTokenKey, value: _token); } } else { + // Validate the existing token. + _tokenIsValid = await twitchApi.validateToken(token: _token!); + + // If the token is invalid, logout. + if (!_tokenIsValid) return await logout(); + // Initialize the user store. await user.init(headers: headersTwitch); if (user.details != null) _isLoggedIn = true; } - // Validate the token. - _tokenIsValid = await twitchApi.validateToken(token: _token!); - - // If the token is invalid, logout. - if (!_tokenIsValid) await logout(); - _error = null; } catch (e) { debugPrint(e.toString());