createChallenge method
Future<SecretChallenge>
createChallenge(
- Session session, {
- required String verificationCode,
- required Transaction transaction,
Creates a new SecretChallenge from a verification code.
This method:
- Generates the hash of
verificationCode - Creates and inserts a SecretChallenge record
Returns the created SecretChallenge with its database ID.
The verificationCode should be generated by the caller and sent to the
user via the appropriate channel (email, SMS, etc.).
Implementation
Future<SecretChallenge> createChallenge(
final Session session, {
required final String verificationCode,
required final Transaction transaction,
}) async {
final verificationCodeHash = await _hashUtil.createHashFromString(
secret: verificationCode,
);
return SecretChallenge.db.insertRow(
session,
SecretChallenge(
challengeCodeHash: verificationCodeHash,
),
transaction: transaction,
);
}