authenticate method
Implementation
Future<AuthSuccess> authenticate(
Session session, {
required final String idToken,
}) async {
return session.db.transaction((final transaction) async {
final account = await GoogleAccounts.authenticate(
session,
idToken: idToken,
transaction: transaction,
);
if (account.authUserNewlyCreated) {
await UserProfiles.createUserProfile(
session,
account.authUserId,
UserProfileData(
fullName: account.details.fullName.trim(),
email: account.details.email,
),
transaction: transaction,
);
if (Uri.tryParse(account.details.image) case Uri imageUri) {
try {
await UserProfiles.setUserImageFromUrl(
session,
account.authUserId,
imageUri,
transaction: transaction,
);
} catch (e, stackTrace) {
session.log(
'Failed to import profile image from Google account.',
level: LogLevel.error,
exception: e,
stackTrace: stackTrace,
);
}
}
}
return _createSession(
session,
account.authUserId,
transaction: transaction,
);
});
}