NAME
RegToken
—
Manage Matrix client registration
tokens.
SYNOPSIS
#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
*);
TYPE DECLARATIONS
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.
DESCRIPTION
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.
void RegTokenUse(RegTokenInfo *)
``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
RegTokenValid
()
to see if a token actually can be used.
int RegTokenExists(Db *, char *)
Return a boolean value indicating whether or not the specified token exists in the database.
int RegTokenDelete(RegTokenInfo *)
Delete the specified registration token from the database.
RegTokenInfo * RegTokenGetInfo(Db *, char *)
Retrieve information about the specified registration token from the database.
RegTokenInfo * RegTokenCreate(Db *, char *, char *, unsigned long, int, int)
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.
void RegTokenFree(RegTokenInfo *)
Free the memory associated with the registration token. This
should be called after
RegTokenClose
().
int RegTokenValid(RegTokenInfo *)
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.
int RegTokenClose(RegTokenInfo *)
Unlock the database reference associated with the given
registration token. This should be called before
RegTokenFree
().