The "Reporting" item is hidden unless I am logged in, and the "Logout" is "Login" until authenticated. All I have so far is an event on the menu that sets a custom prop to true if the user is authenticated, and a script that runs every time the menu is clicked.
def runAction(self, event):
if self.custom.auth == True:
system.perspective.logout()
else:
system.perspective.login()
This does not work very well, because on each click event I am asked to login. So, what needs to happen to make this work?
Can I get the menu item that was clicked, such as the "Login/out" item? Which is index 2 in this case.
if not self.custom.auth and event.path == 2:
system.perspective.login()
elif self.custom.auth and event.path == 2:
system.perspective.logout()
Except, "Reporting" is not visible until logged in, therefore the event.path = 2 will not work as 2 does not exist at that time...
So,
if not self.custom.auth and event.label == 'Login':
system.perspective.login()
elif self.custom.auth and event.label == 'Logout':
system.perspective.logout()
This works. Is this an acceptable practice for allowing a login/out for something that would not normally require authentication?