Authentication

Authentication is built in Typetron and configured for you out of the box. All the magic happens inside AuthController that comes with the blank Typetron app. Inside, there are two methods that take care of registering and logging in users.

You can check the config/auth.ts file to see the different configuration options.

Creating a new user

If you want to create a new user, simply make a POST request to the /register endpoint giving it an email, password and a password confirmation as in the following image, and you will have a user created in your database.

{
    "email": "john@example.com",
    "password": "myPassword",
    "passwordConfirmation": "myPassword"
}

Logging in a user

You can now log-in with your newly created user by making a POST request to the /login route providing the email and the password:

{
    "email": "john@example.com",
    "password": "myPassword"
}

You will be getting a JWT token back that you can use to authenticate the user in your app.