RegToken(3) Library Functions Manual RegToken(3)

RegTokenManage Matrix client registration tokens.

#include <RegToken.h>

void
RegTokenUse(RegTokenInfo *);

int
RegTokenExists(Db *, char *);

int
RegTokenDelete(RegTokenInfo *);

RegTokenInfo *
RegTokenGetInfo(Db *, char *);

RegTokenInfo *
RegTokenCreate(Db *, char *, char *, unsigned long, int, int);

void
RegTokenFree(RegTokenInfo *);

int
RegTokenValid(RegTokenInfo *);

int
RegTokenClose(RegTokenInfo *);

typedef  struct RegTokenInfo
{
    Db *db;
    DbRef *ref;

    /*
     * The token itself.
     */
    char *name;

    /*
     * Who created this token. Note that this can be NULL if the
     * token was created by Telodendria itself.
     */
    char *owner;

    /*
     * How many times the token was used.
     */
    int used;

    /*
     * How many uses are allowed.
     */
    int uses;

    /*
     * Timestamp when this token was created.
     */
    unsigned long created;

    /*
     * Timestamp when this token expires, or 0 if it does not
     * expire.
     */
    unsigned long expires;

    /*
     * A bit field describing the privileges this token grants. See
     * the User API documentation for the privileges supported.
     */
    int grants;

} RegTokenInfo;

This structure describes a registration token that is in the database.

RegToken manages registration tokens, which are used to allow specific trusted people to register accounts on a homeserver without necessarily allowing entirely open registration. In Telodendria, registration tokens can also grant privileges to a user upon registration. This allows the initial server administrator account to be granted all privileges when it is created.

``Use'' the specified registration token by increasing the used count by one and writing the changes to the database. This function only takes action if the token is allowed to be used. Check () to see if a token actually can be used.

Return a boolean value indicating whether or not the specified token exists in the database.

Delete the specified registration token from the database.

Retrieve information about the specified registration token from the database.

Create a new registration with the given name, owner, expiration timestamp, number of uses, and privileges to grant, all specified in that order. Upon success, a registration token information structure will be returned. Otherwise, NULL will be returned.

Free the memory associated with the registration token. This should be called after ().

Return a boolean value indicating whether or not the specified token is valid. A registration token is only valid if it has not expired and still has at least one remaining use.

Unlock the database reference associated with the given registration token. This should be called before ().

User(3)

April 29, 2023 Telodendria