deleteSession method
- SessionId? id,
- MyUserCredentials? confirmation,
- AccessTokenSecret? token,
Destroys the specified Session of the authenticated MyUser, or the
current one (if the id
argument is not provided).
If the id
argument is provided, then the confirmation argument is
mandatory, unless the authenticated MyUser has no means for it (has
neither MyUser.hasPassword, nor
MyUserEmails.confirmed/MyUserPhones.confirmed).
User-Agent
HTTP header must be specified for this mutation and meet the
UserAgent scalar format.
Authentication
Mandatory.
Result
Only the following SessionEvent may be produced on success:
EventSessionDeleted
.
Idempotent
Succeeds as no-op (and returns no SessionEvent
) if the specified
Session has been deleted already.
However, always uses the provided ConfirmationCode, disallowing to use it again.
Implementation
Future<void> deleteSession({
SessionId? id,
MyUserCredentials? confirmation,
AccessTokenSecret? token,
}) async {
token ??= this.token;
Log.debug(
'deleteSession(id: $id, confirmation: ***, token: $token)',
'$runtimeType',
);
if (token != null) {
final variables = DeleteSessionArguments(
id: id,
confirmation: confirmation,
);
final QueryResult result = await client.mutate(
MutationOptions(
operationName: 'DeleteSession',
document: DeleteSessionMutation(variables: variables).document,
variables: variables.toJson(),
),
onException:
(data) => DeleteSessionException(
(DeleteSession$Mutation.fromJson(data).deleteSession
as DeleteSession$Mutation$DeleteSession$DeleteSessionError)
.code,
),
raw: RawClientOptions(token),
);
GraphQlProviderExceptions.fire(result);
}
}