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

Set Expiry manually while Save Session and Save User Method #45

Open
velhari opened this issue Jul 24, 2019 · 0 comments
Open

Set Expiry manually while Save Session and Save User Method #45

velhari opened this issue Jul 24, 2019 · 0 comments

Comments

@velhari
Copy link

velhari commented Jul 24, 2019

Hi

Can you add a parameter in saveSession and saveUser Method to set cookie expiry manually instead of assigning at the initial level.

Because consider this use-case. In Login form there is a option called "RememberMe". if the user select this option means we have to set expiry to future date. So for this type of use-case if you allow this default parameter means it will be helpful.

key: 'saveUser',
value: function saveUser(user, expires=null) {
return new Promise(function (resolve) {
if (instance.server) {
instance[_constants.USER_DATA] = user;
instance.store.dispatch((0, _actions.getUserSessionSuccess)(user));
resolve();
} else if (instance.driver === 'COOKIES') {
Cookies.set(_constants.USER_DATA, user, { expires: expires == null ? instance.expires : expires });
instance.store.dispatch((0, _actions.getUserSessionSuccess)(user));
resolve();
} else {
instance.storage.setItem(_constants.USER_DATA, user).then(function (user) {
instance.store.dispatch((0, _actions.getUserSessionSuccess)(user));
resolve();
}).catch(function () {
instance.store.dispatch((0, _actions.getUserSessionSuccess)(user));
Cookies.set(_constants.USER_DATA, user, { expires: expires == null ? instance.expires : expires });
resolve();
});
}
});
}
}

Thanks,
Velu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant