getAccessTokenPayloadSecurely static method
Implementation
static Future<Map<String, dynamic>> getAccessTokenPayloadSecurely() async {
Map<String, dynamic>? frontToken = await FrontToken.getToken();
if (frontToken == null)
throw SuperTokensException("Session does not exist");
int accessTokenExpiry = frontToken['ate'] as int;
Map<String, dynamic> userPayload = frontToken['up'] as Map<String, dynamic>;
if (accessTokenExpiry < DateTime.now().millisecondsSinceEpoch) {
bool retry = await SuperTokens.attemptRefreshingSession();
if (retry)
return getAccessTokenPayloadSecurely();
else
throw SuperTokensException("Could not refresh session");
}
return userPayload;
}