signOut method
Implementation
Future<AuthResponse<T>> signOut({
Provider? provider,
Object? args,
String? id,
bool notifiable = true,
}) async {
try {
provider ??= (await _auth)?.provider;
emit(
args: args,
id: id,
notifiable: notifiable,
AuthResponse.loading(provider, AuthType.logout),
);
final response = await delegate.signOut(provider);
if (!response.isSuccessful) {
return emit(
args: args,
id: id,
notifiable: notifiable,
AuthResponse.failure(
response.error,
provider: provider,
type: AuthType.logout,
),
);
}
final data = await _auth;
if (data == null) {
return emit(
args: args,
id: id,
notifiable: notifiable,
AuthResponse.unauthenticated(
msg: msg.signOut.done,
provider: provider,
type: AuthType.logout,
),
);
}
await update({
AuthKeys.i.loggedIn: false,
AuthKeys.i.loggedOutTime: EntityHelper.generateTimeMills,
});
if (data.isBiometric) {
await _update(
hasAnonymous: false,
id: data.id,
updates: {
...data.extra ?? {},
AuthKeys.i.loggedIn: false,
AuthKeys.i.loggedOutTime: EntityHelper.generateTimeMills,
},
);
} else {
await _delete();
}
return emit(
args: args,
id: id,
notifiable: notifiable,
AuthResponse.unauthenticated(
msg: msg.signOut.done,
provider: provider,
type: AuthType.logout,
),
);
} catch (error) {
return emit(
args: args,
id: id,
notifiable: notifiable,
AuthResponse.failure(
msg.signOut.failure ?? error,
provider: provider,
type: AuthType.logout,
),
);
}
}