websanova / vue-auth

A simple light-weight authentication library for Vue.js
MIT License
2.36k stars 380 forks source link

Add Additional check for a function for the Cookie Expiration #671

Open jawa-the-hutt opened 2 years ago

jawa-the-hutt commented 2 years ago

With this PR, you can now update the cookie expiration dynamically based on a function call. Addresses https://github.com/websanova/vue-auth/issues/669

Cookie can be setup as such:

cookie: {
  Path: '/',
  Secure: true,
  Expires: expiresAt(),  // accepts a custom function name and parameters if needed
  SameSite: 'Strict'
},
websanova commented 2 years ago

Hmm, not quite sure what you're trying to achieve now, if you want to pass a function I think it should be like this.

if (typeof val === 'string') {
    return val;
}
else if (typeof val === 'function') {
    return val();
}

Otherwise it will just return a function. But not sure if you're having something else in mind?