DEV Community

Cover image for FoalTS framework - Version 2.9 is here 🎉
Loïc Poullain
Loïc Poullain

Posted on

FoalTS framework - Version 2.9 is here 🎉

Version 2.9 of Foal has been released! Here are the improvements that it brings.

New OAuth2 Twitter Provider

After LinkedIn, Google, Github and Facebook, Foal now supports Twitter for social authentication.

👉 Link to the documentation

A big thanks to @LeonardoSalvucci for having implemented this feature.

// 3p
import { Context, dependency, Get } from '@foal/core';
import { TwitterProvider } from '@foal/social';

export class AuthController {
  @dependency
  twitter: TwitterProvider;

  @Get('/signin/twitter')
  redirectToTwitter() {
    // Your "Login In with Twitter" button should point to this route.
    // The user will be redirected to Twitter auth page.
    return this.twitter.redirect();
  }

  @Get('/signin/twitter/callback')
  async handleTwitterRedirection(ctx: Context) {
    // Once the user gives their permission to log in with Twitter, the OAuth server
    // will redirect the user to this route. This route must match the redirect URI.
    const { userInfo, tokens } = await this.twitter.getUserInfo(ctx);

    // Do something with the user information AND/OR the access token.
    // If you only need the access token, you can call the "getTokens" method.

    // The method usually ends with a HttpResponseRedirect object as returned value.
  }

}
Enter fullscreen mode Exit fullscreen mode

OAuth2 Providers support PKCE Code Flow

OAuth2 abstract provider now supports PKCE code flow. If you wish to implement your own provider using PKCE, it's now possible!

Support for version 15 of graphql and latest version of type-graphql

Foal's dependencies have been updated so as to support the latest version of TypeGraphQL.

Original publication: https://foalts.org/blog/2022/05/29/version-2.9-release-notes

Top comments (0)