force basic
This commit is contained in:
parent
0eb0268e01
commit
2962142306
1 changed files with 2 additions and 5 deletions
|
@ -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();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue