force basic

This commit is contained in:
Tobe O 2018-09-11 18:05:42 -04:00
parent 0eb0268e01
commit 2962142306

View file

@ -6,11 +6,8 @@ import 'package:angel_framework/angel_framework.dart';
RequestHandler forceBasicAuth<User>({String realm}) { RequestHandler forceBasicAuth<User>({String realm}) {
return (RequestContext req, ResponseContext res) async { return (RequestContext req, ResponseContext res) async {
if (req.container.has<User>()) return true; if (req.container.has<User>()) return true;
res.headers['www-authenticate'] = 'Basic realm="${realm ?? 'angel_auth'}"';
res throw new AngelHttpException.notAuthenticated();
..statusCode = 401
..headers['www-authenticate'] = 'Basic realm="${realm ?? 'angel_auth'}"'
..close();
}; };
} }