diff --git a/CHANGELOG.md b/CHANGELOG.md index c634eb31..d2989422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.0.2 +* Handle `null` return in `authenticate` + `failureRedirect`. + # 2.0.1 * Add generic parameter to `options` on `AuthStrategy.authenticate`. diff --git a/lib/src/plugin.dart b/lib/src/plugin.dart index a1ff1cf0..1236d075 100644 --- a/lib/src/plugin.dart +++ b/lib/src/plugin.dart @@ -277,7 +277,7 @@ class AngelAuth { : await strategy.authenticate(req, res, options); if (result == true) return result; - else if (result != false) { + else if (result != false && result != null) { var userId = await serializer(result); // Create JWT @@ -325,7 +325,10 @@ class AngelAuth { res.statusCode == 302 || res.headers.containsKey('location')) return false; - else + else if (options?.failureRedirect != null) { + res.redirect(options.failureRedirect); + return false; + } else throw new AngelHttpException.notAuthenticated(); } } diff --git a/pubspec.yaml b/pubspec.yaml index 628813af..240d08e5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_auth description: A complete authentication plugin for Angel. Includes support for stateless JWT tokens, Basic Auth, and more. -version: 2.0.1 +version: 2.0.2 author: Tobe O homepage: https://github.com/angel-dart/angel_auth environment: