Jump to content

Different DB connection for users.


Bimmer

Recommended Posts

Hi all.

I'm currently looking into how we can build an application where users are to login (via rest call to our existing user database) - and when granted authorization the user should get a selection of databases to choose from.

In case that only one database is available for the user loging in - then no selection is needed and the user is just granted access to the database.

How can this be implemented with the example : http://www.unigui.com/doc/online_help/small-login-form.htm

 

Link to comment
Share on other sites

38 minutes ago, Bimmer said:

Hi all.

I'm currently looking into how we can build an application where users are to login (via rest call to our existing user database) - and when granted authorization the user should get a selection of databases to choose from.

In case that only one database is available for the user loging in - then no selection is needed and the user is just granted access to the database.

How can this be implemented with the example : http://www.unigui.com/doc/online_help/small-login-form.htm

 

There is no difficulties on this.

OK Step by Step:

1. Create an Unigui Project

2. Add a login form

3. In login form, when user click on Buton OK, then test here his acces in your existing user DB.

3.1  If he is registred then :

 • 3.1.1. Send a local session variable on UniDataModule , for example --> nbDataBase :=3  (this user has 3 DB )

 • 3.1.2   If he is registred then ModalResul:=MrOk

If he is not registred then

ModalResul:=MrCancel

 

4. On MainForm Activate event test this :

if UniDataModule.nbDataBase<= 1 THEN  Form1.ShowModal

else 

Form2.ShowModal

 

Form1 : is your working form

Form2 : is a selected DataBase form.

_____________

Kind Regards

Link to comment
Share on other sites

The user is only connected to one database - at any given time.

The userdatabase is not a part of this - and is accessed via rest-api.

So when the user selects one of the three databases - I can just setup the TFDConnection on my datamodule for the users session?

 

Link to comment
Share on other sites

18 minutes ago, Bimmer said:

So when the user selects one of the three databases - I can just setup the TFDConnection on my datamodule for the users session?

Yes :)

But, when you say "...and is accessed via rest-ap"

can you explain more (from an other application. Not unigui ?)

Link to comment
Share on other sites

Just now, Abaksoft said:

Yes :)

 

But, when you say "...and is accessed via rest-ap"

can you explain more (from an other application. Not unigui ?)

Thanks.

And yes I can explain. 

We have a setup where all users are registerede in a user database that we maintain ourself. We could go with some sevice that provides this - but we found a way to do it ourselves. We have developed an api (not unigui - with dmvc framework (Daniele Teti) - that handles our login and returns information when login is validated.

So I want to use this in the sample application from unigui. And is thinking something like this would be ok.

 

procedure TfrmLogin.btnLoginClick(Sender: TObject);
var
  lUserdatabase: string;
begin
  if THandlerAuth.Login(edMail.text, edPassword.text, lUserdatabase) then
  begin
    if UniMainModule.SetupDatabaseConnection(lUserdataBase) then
      ModalResult := mrOK;
  end;
end;

This scenario only accepts 1 database. But it could be different for each user.

I already have the handler working - since its based on working api solution. So all I need is confirmation that this is the way to go for a unigui application. 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...