Lifecycle
Admin
CALL Base_Users_Create_Admin( 'Forgotten_password2020#' );
CALL Base_Users_Admin_Reset_Password( 'admin', 'Password2020#' );
CALL Base_Users_Sessions_Replace( 'admin', 'Password2020#' );
SELECT sid INTO @admin FROM base_users_sessions ORDER BY created DESC LIMIT 1;
CALL Base_APIKeys_Create( @admin );
SELECT apikey INTO @admin_apikey FROM base_apikeys ORDER BY APIKEY_ID DESC LIMIT 1;
CALL Base_Users_Sessions_Terminate( @admin );
Users
The following procedures may be used to create and manipulate user accounts. It is expected that these stored procedures will be wrapped by a custom stored procedure that has sufficient privileges to manipulate the tables involved.
In particulary, any wrapping procedure needs to ensure that non-authenticated users can only create accounts of an appropriate type.
CALL Base_Users_Create ( 'mary@example.com', 'Password2020#', 'Mary', 'Swanson', 'USER' );
CALL Base_Users_Sessions_Replace_Inout( 'mary@example.com', 'Password2020#', @status, @mary, @MARY_ID, @mary_type );
CALL Base_Users_Create_Quietly ( 'tom@example.com', 'Password2020#', 'Tom', 'Bombadil', 'USER', FALSE );
CALL Base_Users_Sessions_Replace_Inout( 'tom@example.com', 'Password2020#', @status, @tom, @TOM_ID, @tom_type );
Groups
CALL Base_Groups_Create( @mary, 'Group Mary', 'MARY' );
SET @GROUP_ID = LAST_INSERT_ID();
CALL Base_Groups_Members_Add( @mary, @GROUP_ID, @MARY_ID, TRUE );
CALL Base_Groups_Members_Add( @mary, @GROUP_ID, @TOM_ID, FALSE );
Places
CALL Base_Places_Create_Inout( @mary, '', '8 Navigator Place, Hendra, 4011', '', @HENDRA_PLACE_ID );
CALL Base_Places_Create_Inout( @mary, '', '88 Norman Avenue, Norman Park, 4170', '', @NORMAN_PLACE_ID );
Places Routes
CALL Base_Places_Routes_Create( @mary, '', @HENDRA_PLACE_ID, @NORMAN_PLACE_ID, 0, 0 );
SET @ROUTE_ID = LAST_INSERT_ID();
CALL Base_Places_Routes_Save( @mary, '', @ROUTE_ID, 'route_distance_metres', 1000 );
CALL Base_Places_Routes_Save( @mary, '', @ROUTE_ID, 'route_duration_seconds', 1000 );
CALL Base_Places_Unprocessed( '', @admin_apikey );