totaljs / framework4

Total.js framework v4
https://www.totaljs.com
Other
99 stars 36 forks source link

`AUTH` delegate does not throw 404 errors #22

Closed fgnm closed 2 years ago

fgnm commented 2 years ago

Hi, as title I've noticed that when using AUTH delegate framework doesn't throw 404 errors anymore, I don't know am I missing something here?

This is my auth.js file, but the issue can be noticed in example too.

MAIN.session = SESSION();

// Delegate for loading session data
MAIN.session.ondata = function(meta, next) {
    FUNC.rdbms.get('SELECT * FROM user WHERE id = :id', { id: meta.id })
    .then(result => {
        next(null, result);
    }).catch(err => {
        next(err, null);
    });
};

AUTH(function($) {
    // Session options:
    var opt = {};
    opt.name = CONF.cookie;
    opt.key = CONF.cookie_secret;
    opt.expire = '3 days';

    // opt.options = {};           // Optional, a cookie options when the the cookie is extended (default: { httponly: true, security: 'lax' })
    opt.ddos = 5;

    MAIN.session.getcookie($, opt, $.done());
});

Whenever I try to open a page that shouldn't exists, framework return 401 error page. I'm using total4 0.0.44. Thanks

petersirka commented 2 years ago

Hi @fgnm, It throws 401 and you can catch it via ROUTE('#401', ...)

Whenever I try to open a page that shouldn't exists, framework return 401 error page. I'm using total4 0.0.44.

I'm going to check it.

petersirka commented 2 years ago

Yes, there is a bug. I'll solve it. Thank you!

petersirka commented 2 years ago

Fixed, please try it $ npm install total4@beta.

fgnm commented 2 years ago

@petersirka thanks now it works!