[Solved] Base - Startup forms based on authentication

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

[Solved] Base - Startup forms based on authentication

Post by gkick »

Hi,

Playing around with this for some time but not getting anywhere.
Frontend opens calling backend authentication, if the user is SA I want to open the admin form, if its somebody else I want to open a specific user form

The following will actually open both ?

Code: Select all

Sub choose()
	If CURRENT_USER = SA Then
			Call OpenAdmin
	End If
	
	If CURRENT_USER <> SA Then
			Call OpenLogInOut
	End if
End Sub
Does not matter if I use "SA" or SA or USER, CURRENT_USER or SESSION_USER
Same result if I use else instead of 2 ifs

In addition the procedure runs prior to the authentication prompt even though its called from the setup (from the splitdb) procedure which sets the authentication prompt for the user name to a null string.

The setup macro is called from the documents on open event. (See attached link)

https://www.dropbox.com/s/qj48930vgfdye ... B.rar?dl=0

Logins SA no password or joe pw pass
Any idea how I can solve this, thks and happy 2020 to all !
Last edited by gkick on Sun Feb 02, 2020 3:24 pm, edited 1 time in total.
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Base - startup forms based on authentication

Post by Villeroy »

Create your own log-in dialog.

Code: Select all

If oLogInDialog.execute() = 1 then
sUser = oLogInDialog.Name_Input.getString()
sPwd = oLogInDialog.Password_Input.getString()

on error goto errLogin
  oCon = oDB.getConnection(sUser, sPwd)
on error goto 0

Select case sUser
Case in "SA", "Admin", "Master", "Superman"
  sForm = "Admin Form"
Case in "Mickey", "Dickie", "Pluto", "Donald"
 sForm = "User Form"
Case else
  sForm = "Readme Form"
End select
else
  msgbox "Log-In canceled"
endif
exit sub
errLogin:
Msgbox "Invalid login"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: Base - startup forms based on authentication

Post by gkick »

Thank you, this will replace the setup macro to avoid the primary login ? Will get cracking!

mfg
GK
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
Post Reply