diff --git a/lib/middleware/require_auth.dart b/lib/middleware/require_auth.dart index e4e4b436..19c60841 100644 --- a/lib/middleware/require_auth.dart +++ b/lib/middleware/require_auth.dart @@ -7,7 +7,7 @@ Future requireAuth(RequestContext req, ResponseContext res, return true; else if (throws) { res.status(HttpStatus.UNAUTHORIZED); - throw new AngelHttpException.NotAuthenticated(); + throw new AngelHttpException.Forbidden(); } else return false; } \ No newline at end of file diff --git a/lib/strategies/local.dart b/lib/strategies/local.dart index 7db160f5..fad52557 100644 --- a/lib/strategies/local.dart +++ b/lib/strategies/local.dart @@ -73,14 +73,19 @@ class LocalAuthStrategy extends AuthStrategy { ..header(HttpHeaders.WWW_AUTHENTICATE, 'Basic realm="$realm"') ..end(); return false; - } else throw new AngelHttpException.NotAuthenticated(); + } else return false; } - req.session['user'] = await Auth.serializer(verificationResult); - if (options.successRedirect != null && options.successRedirect.isNotEmpty) { - return res.redirect(options.successRedirect, code: HttpStatus.OK); - } + else if (verificationResult != null && verificationResult != false) { + req.session['userId'] = await Auth.serializer(verificationResult); + if (options.successRedirect != null && + options.successRedirect.isNotEmpty) { + return res.redirect(options.successRedirect, code: HttpStatus.OK); + } - return true; + return true; + } else { + throw new AngelHttpException.NotAuthenticated(); + } } } diff --git a/pubspec.yaml b/pubspec.yaml index 04e34fa5..9f2662e3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: angel_auth description: A complete authentication plugin for Angel. -version: 1.0.0-dev -author: thosakwe +version: 1.0.0-dev+5 +author: Tobe O homepage: https://github.com/angel-dart/angel_auth dependencies: angel_framework: ">=0.0.0-dev < 0.1.0"