Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Troubles with 3.6.0 version of Typegoose #68

Closed
pgsfredda opened this issue Nov 1, 2017 · 2 comments
Closed

Troubles with 3.6.0 version of Typegoose #68

pgsfredda opened this issue Nov 1, 2017 · 2 comments

Comments

@pgsfredda
Copy link

Hi.
I used an old version of typegoose and all works correctly.
To day I tested the 3.6.0 version of Typegoose and I encountered some troubles.

I tested my project with the 3.5.2 version of Typegoose and it works correctly again.

With the debugger I checked that the execution is looped at the count instance method of 'pgLoginAttemptModel' in the 'getIpUserCount' function.

The source file is:

import * as async from 'async';
export class pgLoginAttempt extends Typegoose {
  
    @prop({ default: '', index: true }) ip: string;
    @prop({ default: '', index: true }) user: string;
    @prop({ default: Date.now()}) time: Date;

}
      
export const pgLoginAttemptModel = new pgLoginAttempt().getModelForClass(pgLoginAttempt, { schemaOptions: { collection: 'pg-login-attempts'}});

protected abuseFilter(successEvent: string) {

        let getIpCount = (done) => {
            let conditions = { ip: req.app.ip };

            pgLoginAttemptModel.count(conditions, (err, count) => {
                if (err) return done(err);
                done(null, count);
            });
        };

        let getIpUserCount = (done) => {
            let conditions = { ip: req.app.ip, user: req.body.username };

            pgLoginAttemptModel.count(conditions, (err, count) => {
                if (err) return done(err);
                done(null, count);
            });
        };

        let asyncFinally = (err, results) => {
            if (err) return this.emit(this.err, err);

            if (results.ip >= 5 || results.ipUser >= 5) {
                return this.emit(this.fail);
            }
            else {
                this.emit(successEvent);
            }
        };

        async.parallel({ ip: getIpCount, ipUser: getIpUserCount }, asyncFinally);
};
@hasezoey
Copy link
Contributor

@pgsfredda, do you still have this issue with typegoose 5.8+? otherwise could you provide what is wrong / which error?

@hasezoey
Copy link
Contributor

@Ben305 this can be closed as "stale" / "outdated"

@Ben305 Ben305 closed this as completed Sep 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants