setPassword method
Sets the password for the authentication belonging to the given email.
The password
argument is not checked against the configured password
policy.
Throws an EmailAccountNotFoundException in case no account exists for the given email address.
Implementation
Future<void> setPassword(
final Session session, {
required String email,
required final String password,
final Transaction? transaction,
}) async {
email = email.toLowerCase();
var account = (await EmailAccount.db.find(
session,
where: (final t) => t.email.equals(email),
transaction: transaction,
))
.singleOrNull;
if (account == null) {
throw EmailAccountNotFoundException(email: email);
}
final passwordHash = await EmailAccountSecretHash.createHash(
value: password,
);
account = await EmailAccount.db.updateRow(
session,
account.copyWith(
passwordHash: passwordHash.hash.asByteData,
passwordSalt: passwordHash.salt.asByteData,
),
transaction: transaction,
);
}