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
How to change FeathersJs cookies expiration time? #439
Comments
I believe you got your answer in the Slack help channel. Did that solve your issue? As for the "not authenticated" issue, the request is missing the token, more than likely. Are you using Feathers Client or another method of connecting to the server? If you are using the Feathers client, you need to call app.authenticate() before making any other requests. Please let me know how you are connecting and I'll see if I can help more. |
I used that solution, but its not working for me. I am using jquery feathers client. I am using following code in my app.js file. // app.js code // Establish a Socket.io connection // Get the Feathers services we want to use $('.logout').on('click', function() { app.authenticate().then((result) => { This code showing me "not authenticated" issue at userService.find(). Also app.get('user') function not returning any details currently logged in user. Thanks for replaying me. |
Looks like you are using the socketio provider, so the issue is probably related to this: feathersjs-ecosystem/authentication#275 (comment) Try locking the socket connection to use the websocket transport as is demonstrated there. The next version will automatically take care of this. |
I checked that article, but my issue is different. Feather cookies expired, before my code complete its execution. I am trying to fix this issue. If you have any idea about changing expiration time. Please guide me. I am using https://docs.feathersjs.com/authentication/readme.html#cookie-options as reference. My configure default.json as following: |
Weird. I thought I just fixed this in the docs, but I guess it got lost. It uses Express cookie settings, so change 'expires' to 'maxAge' |
@cwsdeepak @marshallswain's suggestion works with newer beta versions of auth but if you are usin v0.7.x you can hack around it by setting Sorry it's kind of hack will be much easier in the 1.0 version of auth. |
@marshallswain @ekryski I checked my package.json and find out that I am using 0.7.11 version of feathers-authentication. |
@cwsdeepak ok cool. Try you need to do what I mentioned above. Try this: let authOptions = app.get('auth');
const now = new Date();
const DAYS = 2;
authOptions.cookie.expires = now.setTime( now.getTime() + DAYS * 86400000 );
app.set('auth', authOptions);
app.configure(authentication(authOptions)); |
@ekryski I used your solution and its working for me. Thanks @ekryski and @marshallswain for helping |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I am new in feathersjs. I setup feathersjs with MongoDb my system and its working fine. For my website, I want to modify cookies expiration time (default 30 second). I already checked feathersjs document for this issue. Below is the link: https://docs.feathersjs.com/authentication/readme.html#cookie-options
I also getting an error while executing any query with feathersjs. "Uncaught (in promise) Error: You are not authenticated.".
Can anyone help me in fixing this issue?
Thanks in advance.
The text was updated successfully, but these errors were encountered: