platform/lib/middleware/require_auth.dart

10 lines
323 B
Dart
Raw Normal View History

2016-05-03 04:13:19 +00:00
part of angel_auth;
/// Restricts access to a resource via authentication.
Future<bool> requireAuth(RequestContext req, ResponseContext res,
{bool throws: true}) async {
if (req.session.containsKey('userId'))
return true;
else if (throws) throw new AngelHttpException.NotAuthenticated();
else return false;
}