Bimmer Posted October 2, 2023 Share Posted October 2, 2023 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 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 2, 2023 Share Posted October 2, 2023 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 Quote Link to comment Share on other sites More sharing options...
Bimmer Posted October 2, 2023 Author Share Posted October 2, 2023 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? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 2, 2023 Share Posted October 2, 2023 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 ?) Quote Link to comment Share on other sites More sharing options...
Bimmer Posted October 2, 2023 Author Share Posted October 2, 2023 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. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 2, 2023 Share Posted October 2, 2023 44 minutes ago, Bimmer said: So all I need is confirmation that this is the way to go for a unigui application. Yes, you can go with this way. Quote Link to comment Share on other sites More sharing options...
Bimmer Posted October 2, 2023 Author Share Posted October 2, 2023 11 minutes ago, Abaksoft said: Yes, you can go with this way. Thanks. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 2, 2023 Share Posted October 2, 2023 1 minute ago, Bimmer said: Thanks. Your coding is elegand, it works fine. See in attachment. Test.7z Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.