From 12c46e3ac6661ea0afc09867f86aa959d7a8f793 Mon Sep 17 00:00:00 2001 From: Mihail Varbanov Date: Wed, 23 Dec 2020 12:51:28 +0200 Subject: [PATCH] Updated backward compatibility for versions prior to rokmetro auth scheme (#396). --- lib/service/Auth.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/service/Auth.dart b/lib/service/Auth.dart index d3b28db4..d97cb1bc 100644 --- a/lib/service/Auth.dart +++ b/lib/service/Auth.dart @@ -107,11 +107,8 @@ class Auth with Service implements NotificationsListener { _userPiiCacheFile = await _getUserPiiCacheFile(); _userPiiData = await _loadUserPiiDataFromCache(); - // Backward compatability - if ((_authToken != null) && (_rokmetroToken == null)) { - _rokmetroToken = await _loadRokmetroToken(optAuthToken: _authToken); - _rokmetroUser = await _loadRokmetroUser(optRokmetroToken: _rokmetroToken); - } + // Backward compatability - no rokmetro data stored from previous versions + await _ensureRokmetroData(); _syncProfilePiiDataIfNeed(); // No need for await } @@ -665,6 +662,15 @@ class Auth with Service implements NotificationsListener { return null; } + Future _ensureRokmetroData() async { + if ((_authToken != null) && (_rokmetroToken == null)) { + Storage().rokmetroToken = _rokmetroToken = await _loadRokmetroToken(optAuthToken: _authToken); + } + if ((_rokmetroToken != null) && (_rokmetroUser == null)) { + Storage().rokmetroUser = _rokmetroUser = await _loadRokmetroUser(optRokmetroToken: _rokmetroToken); + } + } + /// UserPIIData Future _loadPidWithPhoneAuth({String phone, AuthToken optAuthToken}) async {