Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null to be passed for the ttl #124

Merged
merged 1 commit into from Aug 9, 2016
Merged

Allow null to be passed for the ttl #124

merged 1 commit into from Aug 9, 2016

Commits on Apr 15, 2016

  1. Allow null to be passed for the ttl

    `null` is a valid default option for the `ttl` of the cookie but the schema isn't currently allowing it.
    
    As an example, in our case the value for `ttl` is coming from an external place; from a configuration system which sets it on a per-env basis.
    In test/development the `ttl` might be set to an explicit value whereas in production it might be `null` 
    
    ```js
            server.auth.strategy('session', 'cookie', 'try', {
                password: options.cookieOptions.password,
                cookie: 'ssosid',
                ttl: options.cookieOptions.ttl,
                domain: options.cookieOptions.domain,
                redirectOnTry: false,
                appendNext: true,
                clearInvalid: true,
                isSecure: true,
                isHttpOnly: true,
                validateFunc: validate
            });
    ```
    
    We can work around this easily by doing something like:
    ```js
            const strategyOptions = {
                password: options.cookieOptions.password,
                cookie: 'ssosid',
                domain: options.cookieOptions.domain,
                redirectOnTry: false,
                appendNext: true,
                clearInvalid: true,
                isSecure: true,
                isHttpOnly: true,
                validateFunc: validate
            };
    
            if(options.cookieOptions.ttl) {
                strategyOptions.ttl = options.cookieOptions.ttl;
            }
    
            server.auth.strategy('session', 'cookie', 'try', strategyOptions);
    ```
    
    However, it just felt a little cleaner to have the `ttl` schema accept a valid cookie ttl value.
    
    Thoughts?
    briandela committed Apr 15, 2016
    Copy the full SHA
    150c956 View commit details
    Browse the repository at this point in the history