diff --git a/packages/auth/example/example.dart b/packages/auth/example/example.dart index 6abdd1b8..85478101 100644 --- a/packages/auth/example/example.dart +++ b/packages/auth/example/example.dart @@ -17,6 +17,7 @@ void main() async { // If authentication succeeds, return a User object. // // Otherwise, return `null`. + return null; }); app.post('/auth/local', auth.authenticate('local')); diff --git a/packages/auth/lib/src/auth_token.dart b/packages/auth/lib/src/auth_token.dart index fda46c4f..be24d29f 100644 --- a/packages/auth/lib/src/auth_token.dart +++ b/packages/auth/lib/src/auth_token.dart @@ -86,7 +86,7 @@ class AuthToken { // var headerString = decodeBase64(split[0]); var payloadString = decodeBase64(split[1]); - var data = split[0] + '.' + split[1]; + var data = '${split[0]}.${split[1]}'; var signature = base64Url.encode(hmac.convert(data.codeUnits).bytes); if (signature != split[2]) { @@ -102,9 +102,9 @@ class AuthToken { String serialize(Hmac hmac) { var headerString = base64Url.encode(json.encode(_header).codeUnits); var payloadString = base64Url.encode(json.encode(toJson()).codeUnits); - var data = headerString + '.' + payloadString; + var data = '$headerString.$payloadString'; var signature = hmac.convert(data.codeUnits).bytes; - return data + '.' + base64Url.encode(signature); + return '$data.${base64Url.encode(signature)}'; } Map toJson() { diff --git a/packages/auth/lib/src/strategies/local.dart b/packages/auth/lib/src/strategies/local.dart index cca1ffbf..d4d8b68f 100644 --- a/packages/auth/lib/src/strategies/local.dart +++ b/packages/auth/lib/src/strategies/local.dart @@ -39,7 +39,7 @@ class LocalAuthStrategy extends AuthStrategy { @override Future authenticate(RequestContext req, ResponseContext res, [AngelAuthOptions? options]) async { - var _options = options ?? AngelAuthOptions(); + var localOptions = options ?? AngelAuthOptions(); User? verificationResult; if (allowBasic) { @@ -88,9 +88,9 @@ class LocalAuthStrategy extends AuthStrategy { if (verificationResult == null || (verificationResult is Map && verificationResult.isEmpty)) { - if (_options.failureRedirect != null && - _options.failureRedirect!.isNotEmpty) { - await res.redirect(_options.failureRedirect, code: 401); + if (localOptions.failureRedirect != null && + localOptions.failureRedirect!.isNotEmpty) { + await res.redirect(localOptions.failureRedirect, code: 401); return null; }