Fixed "failureRedirect" test case

This commit is contained in:
thomashii 2021-06-01 08:49:59 +08:00
parent a30201ebb1
commit 05a45bee4f
2 changed files with 4 additions and 3 deletions

View file

@ -8,7 +8,7 @@ bool _validateString(String? str) => str != null && str.isNotEmpty;
/// Determines the validity of an incoming username and password.
// typedef FutureOr<User> LocalAuthVerifier<User>(String? username, String? password);
typedef LocalAuthVerifier<User> = FutureOr<User> Function(
typedef LocalAuthVerifier<User> = FutureOr<User?> Function(
String? username, String? password);
class LocalAuthStrategy<User> extends AuthStrategy<User> {

View file

@ -13,11 +13,12 @@ var localOpts = AngelAuthOptions<Map<String, String>>(
failureRedirect: '/failure', successRedirect: '/success');
Map<String, String> sampleUser = {'hello': 'world'};
Future<Map<String, String>> verifier(String? username, String? password) async {
Future<Map<String, String>?> verifier(
String? username, String? password) async {
if (username == 'username' && password == 'password') {
return sampleUser;
} else {
throw ArgumentError('Unexpected type for data');
return null;
}
}