Version: 2.5.0 (latest)

Adding Sign Up

So far, only users created with the create-user script can log in and publish stories. In this section you will add a new API endpoint for users to sign up with the registration page.

API endpointMethodDescription
/api/auth/signupPOSTRegisters a new user. An email and a password are expected in the request body.

Open the auth.controller.ts file and add a new route.

import { Context, hashPassword, HttpResponseNoContent, HttpResponseOK, HttpResponseUnauthorized, Post, Session, ValidateBody, verifyPassword } from '@foal/core';
import { User } from '../../entities';
const credentialsSchema = {
// ...
export class AuthController {
// login...
// logout...
async signup(ctx: Context<User|undefined, Session>) {
const email =;
const password = ctx.request.body.password;
const user = new User(); = email;
user.avatar = ''; = 'Unknown';
user.password = await hashPassword(password);
ctx.user = user;
return new HttpResponseOK({

If you go the sign up page, you should now be able to register as a new user.