issueMagicLink method
Issues a magic link for identifier.
baseUrl receives the token as a query parameter, so the link is
whatever route the application already serves.
Implementation
Future<DVMagicLink> issueMagicLink(
String identifier, {
required Uri baseUrl,
String parameter = 'token',
}) async {
final token = _secret(32);
final expiresAt = DateTime.now().add(lifetime);
await store.put(
_lookupForLink(token),
DVAuthTokenRecord(
identifier: identifier,
hash: _hash(token),
expiresAt: expiresAt,
),
);
return DVMagicLink(
url: baseUrl.replace(
queryParameters: <String, String>{
...baseUrl.queryParameters,
parameter: token,
},
),
token: token,
expiresAt: expiresAt,
);
}