Chromia
Start Building

10 / 20Module 1: A Rell backend with FT4 accounts

Authentication with FT4 accounts

The auth module gives you a simple way to authenticate users through FT4 accounts. First, import the auth library:

rell
import lib.ft4.auth;

Next, call auth.authenticate inside your operations to verify the user. Because this function takes care of authentication for you, there is no need to pass the user's public key into every operation by hand, which keeps your code both safer and simpler.

Authentication only works once you register an auth handler. Add the following to your Rell module:

rell
@extend(ft4_auth.auth_handler)function () = ft4_auth.add_auth_handler(    flags = []);

This extension function registers a new auth handler that applies globally, so every operation calling auth.authenticate is authenticated through it.

Written for this site from Chromia’s public course. Code samples are the course’s own.