Telegram_2022-09-01T10

<< Click to Display Table of Contents >>

Navigation:  Telegram > 2022 > 09 > 01 >

Telegram_2022-09-01T10

Telegram link

 

2022-09-01T10:09:14

 

Make sure you use the OnDestroy event of the UserSession to call a function that allows the user back in ( whether you use true/false or 0/1 etc ).

 

You will most likely have to create a user maintenance screen ( list of users ) and the ability for a user ( who has administrator rights ), to be able to manually set the user's access back to true.

 

A lot of times I use a field called \User.IsEnabled Y/N\, but if i want to allow multiple connections, then I use another field called User.ActiveCount and I use 0,1,2,3 etc...

 

I do not think there is a way around when a session dies and the function did not run, as a result. So that is why you have to have an administrator screen that allows a user with \user.IsAdmin\ rights to be able to edit other users information. Does that make sense ?

 


 

Telegram link

 

2022-09-01T10:38:57

 

so in your user table, like \sys_user\,... add a field called \IsActive\ and set it to type character of 1, default value \Y\ ).

 

you might have to add an index for that field, not sure.

 

then write a function in the userSession called something like \SetUserActive\...

 

function SetUserActive( iUserID: LongInt; bIsActive: Boolean ): boolean ;

 

then in that code....

 

result := False ;

 

with sys_user do

 

begin

 

// put code here to make sure it is active/open etc. . .

 

if Locate( 'user_id', iUserID, [ loCaseInsensitive ]) then

 

begin

 

Edit ;

 

if bIsActive then

 

FieldByName('IsActive').AsString := 'Y'

 

else

 

FieldByName('IsActive').AsString := 'N' ;

 

Post ;

 

Result := True ;

 

end

 

end ;

 

// write some code to deal with if result is false, you could not change the value and

 

// whatever you want to notify yourself that the system has a problem.

 

// session was closed incorrectly

 

Then,... in your login page and code you will need to add

 

when the user is logged in, set a variable like \FUSER_ID := FieldByName('user_id').AsInteger ;

 

( if successfully logged in,.... \UserSession.SetUserActive( FUSER_ID, 'Y' );

 

( of course, I am passing the USER_ID, the autoincrement value in the user table )

 

when the user is logged out,

 

UserSession.SetUserActive( FUSER_ID, 'N' );

 

FUSER_ID := -1 ;

 

and also when the session is destroyed...

 

UserSession.SetUserActive( FUSER_ID, 'N' );

 

FUSER_ID := -1 ;

 

Does that make sense ?

 


 

Telegram link

 

2022-09-01T10:39:50

 

there are many ways to do this, i'm just writing something off the top of my head. apologies for the rush as I am coding on another project now.