public UserService(IUserStoreDatabaseSettings settings, IOptions <CommonSettings> commonSettings, DatabaseEncryptionService encryptionService, IRoleService roleService) { _roleService = roleService; _identitySettings = commonSettings.Value.IdentitySettings; _encryptionService = encryptionService; var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _users = database.GetCollection <DbUser>(settings.UsersCollectionName); }
public TokenService(ITokenStoreDatabaseSettings settings, DatabaseEncryptionService encryptionService) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _tokens = database.GetCollection <DbToken>(settings.TokensCollectionName); var indexKeysDefinition = Builders <DbToken> .IndexKeys.Ascending(t => t.ExpireAt); _tokens.Indexes.CreateOne ( new CreateIndexModel <DbToken>(indexKeysDefinition, new CreateIndexOptions { ExpireAfter = TimeSpan.Zero }) ); }