We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Logging users out in Foal is not simple and intuitive. It requires a lot of settings that one might not understand.
Remove extendLifeTimeOrUpdate and removeSessionCookie.
extendLifeTimeOrUpdate
removeSessionCookie
Before
import { dependency, Context, HttpResponseNoContent, Post, Session, TokenRequired } from '@foal/core'; import { TypeORMStore } from '@foal/typeorm'; export class AuthController { @dependency store: TypeORMStore; @Post('/logout') @TokenRequired({ extendLifeTimeOrUpdate: false, store: TypeORMStore, }) async logout(ctx: Context<any, Session>) { await this.store.destroy(ctx.session.sessionID); return new HttpResponseNoContent(); } }
After
import { Context, HttpResponseNoContent, Post, TokenOptional } from '@foal/core'; import { TypeORMStore } from '@foal/typeorm'; export class AuthController { @Post('/logout') @TokenOptional({ store: TypeORMStore, }) async logout(ctx: Context) { if (ctx.session) { await ctx.session.destroy(); } return new HttpResponseNoContent(); } }
import { dependency, Context, HttpResponseNoContent, Post, removeSessionCookie, Session, TokenRequired } from '@foal/core'; import { TypeORMStore } from '@foal/typeorm'; export class AuthController { @dependency store: TypeORMStore; @Post('/logout') @TokenRequired({ cookie: true, extendLifeTimeOrUpdate: false, store: TypeORMStore, }) async logout(ctx: Context<any, Session>) { await this.store.destroy(ctx.session.sessionID); const response = new HttpResponseNoContent(); removeSessionCookie(response); return response; } }
import { Context, HttpResponseNoContent, Post, TokenOptional } from '@foal/core'; import { TypeORMStore } from '@foal/typeorm'; export class AuthController { @Post('/logout') @TokenOptional({ cookie: true, store: TypeORMStore, }) async logout(ctx: Context) { if (ctx.session) { await ctx.session.destroy(); } return new HttpResponseNoContent(); } }
See #659
The text was updated successfully, but these errors were encountered:
Implemented in #659.
Sorry, something went wrong.
No branches or pull requests
Problem
Logging users out in Foal is not simple and intuitive. It requires a lot of settings that one might not understand.
Solution
Remove
extendLifeTimeOrUpdate
andremoveSessionCookie
.Examples
Without cookies
Before
After
With cookies
Before
After
Steps
See #659
The text was updated successfully, but these errors were encountered: