jaguar_auth_mongo 0.1.0 icon indicating copy to clipboard operation
jaguar_auth_mongo: ^0.1.0 copied to clipboard

[pending analysis]

Jaguar AuthModelManager for MongoDb backend

jaguar_auth_mongo #

Jaguar AuthModelManager for MongoDb backend

Usage #

A simple usage example:

class BaseApi {
  BasicAuth basicAuth(Context ctx) =>
      new BasicAuth(modelManager(ctx.getInput(MongoDb)));

  Authorizer authorizer(Context ctx) =>
      new Authorizer(modelManager(ctx.getInput(MongoDb)));

  MongoDb mongoDb(Context ctx) => new MongoDb('mongodb://localhost:27018/test');
}

/// This route group contains login and logout routes
@Api()
@WrapOne(#mongoDb)
class AuthRoutes extends BaseApi {
  @Post(path: '/login')
  @WrapOne(#basicAuth)
  void login(Context ctx) {}

  @Post(path: '/logout')
  void logout(Context ctx) {
    //TODO logout
  }
}

/// Collection of routes students can also access
@Api(path: '/book')
@Wrap(const [#mongoDb, #authorizer])
class StudentRoutes extends BaseApi {
  @Get(path: '/all')
  Response<String> getAllBooks(Context ctx) {
    List<Map> ret =
        _books.values.map((Book book) => bookSerializer.toMap(book)).toList();
    return Response.json(ret);
  }

  @Get(path: '/:id')
  Response<String> getBook(Context ctx) {
    final String id = ctx.pathParams.get('id');
    final Book book = _books[id];
    return Response.json(bookSerializer.toMap(book));
  }
}
0
likes
--
pub points
--%
popularity

Publisher

unverified uploader

Jaguar AuthModelManager for MongoDb backend

Homepage

License

unknown (LICENSE)

Dependencies

auth_header, jaguar, jaguar_auth, jaguar_common, jaguar_mongo, jaguar_serializer, jaguar_session, mongo_dart

More

Packages that depend on jaguar_auth_mongo