platform/lib/middleware/serialization.dart

15 lines
405 B
Dart
Raw Normal View History

2016-05-03 04:13:19 +00:00
part of angel_auth;
/// Serializes a user to the session.
typedef Future UserSerializer(user);
/// Deserializes a user from the session.
typedef Future UserDeserializer(userId);
_serializationMiddleware(RequestContext req, ResponseContext res) async {
if (await requireAuth(req, res, throws: false)) {
req.properties['user'] = await Auth.deserializer(req.session['userId']);
}
return true;
}