deleteSession method
- SessionId? id,
- UserPassword? password,
- bool force = false,
Deletes Session with the provided id
, if any, or otherwise Session
of the active MyUser.
Returns the path of the authentication page.
If force
is true
, then the current Credentials will be revoked
unilaterally and immediately.
Implementation
Future<String?> deleteSession({
SessionId? id,
UserPassword? password,
bool force = false,
}) async {
Log.debug('deleteSession($id, $password, force: $force)', '$runtimeType');
if (id != null) {
await _authRepository.deleteSession(id: id, password: password);
return null;
}
status.value = RxStatus.empty();
if (force) {
if (userId != null) {
_authRepository.removeAccount(userId!);
}
return _unauthorized();
}
return await WebUtils.protect(() async {
if (onLogout != null) {
try {
await onLogout?.call();
} catch (e) {
Log.debug('Unable to invoke `onLogout()`: $e', '$runtimeType');
}
onLogout = null;
hasCalls = null;
}
try {
await _authRepository.deleteSession();
} catch (e) {
printError(info: e.toString());
}
return _unauthorized();
});
}