In this bundle we're overriding the persistence layers from SecurityBundle to make them work with MongoBundle.
npm i -S @bluelibs/security-bundle @bluelibs/security-mongo-bundle
import { SecurityBundle } from "@bluelibs/security-bundle";
import { SecurityMongoBundle } from "@bluelibs/security-mongo-bundle";
kernel.addBundle(
new SecurityBundle({
// options
}),
// Order doesn't really matter.
new SecurityMongoBundle()
);
You have the option to make changes to your collections, for example if you user is linked to other collections or you simply want a different collectioName:
import {
UsersCollection,
PermissionsCollection,
} from "@bluelibs/security-mongo-bundle";
import { IUser } from "@bluelibs/security-bundle";
// We make the type behave with all of our needs
interface IAppUser extends IUser {
profileId: ObjectID;
}
class AppUsersCollection extends UsersCollection<IAppUser> {
static collectionName = "User"; // override it, by default it's "users"
static links = {
profile: {
collection: () => ProfilesCollection,
field: "profileId",
},
};
static indexes = [
{
key: {
profileId: 1,
},
},
];
}
new SecurityMongoBundle({
usersCollection: AppUsersCollection,
});
This package is part of BlueLibs family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here