doLogout static method
Starts the logout process
The AuthenticationBloc must be included in the given context
Clears the flutter_secure_storage, returns true if successful
Implementation
static Future<bool> doLogout(BuildContext context) async {
try {
final OpenIdConfiguration conf = await checkAndLoadConfig();
final TokenEntity tokenInfo = await _authStorageHelper.getCurrentToken();
await HTTPHelper.postData(
url:
'${conf.endSessionEndpoint}?access_token_hint=${tokenInfo.accessToken}');
// Clear all local dbs
await _authStorageHelper.deleteToken();
BlocProvider.of<AuthenticationBloc>(context)
.add(AuthenticationLoggedOutEvent());
return true;
} catch (e) {
stderr.addError('Log out failed: ', e as StackTrace?);
}
return false;
}