Skip to content

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

@velhari

Description

@velhari

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions