Skip to main content

Version 2.9 release notes

· 2 min read
Loïc Poullain

Banner

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.
}

}

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.


Share this article on

Stay up to date with the newsletter.