Hi,
Is there a way to run a script after a user get logged in the application.
I tried to do something with the Authentication challenge session event (just writing a log with the system.util.getLogger()) but it's not working.
Any idea ?
Best regards,
Valentin
What are you trying to do ?
I'm trying to affect values to session custom properties when a user get logged in the perspective session
The session startup event should work.
Otherwise, if you can be a bit more accurate about your goal, someone around here might suggest alternative (and maybe better) ways of achieving it.
weird i dont seem to be able to log anything either in this event
Did you mean the startup one, or the auth challenge one ?
the challange
I want to use this event to manage my security.
I created session custom properties as boolean and the goal is to check the role which get logged and affect the value "True" for this customs.
I already know the function HasRole()... But I don't want to use it like that to prevent about some change on group name or something else. I want my security to be centralized in one script.
I'm kind of thinking 'authentication challenge' means something else:
https://docs.inductiveautomation.com/display/DOC81/Component+Events+and+Actions#ComponentEventsandActions-AuthenticationChallengeAction
You could use session.props.auth.user.roles instead.
seems like it yea
I just try an authentication challenge with system.perspective.authenticationChallenge and it triggers successfully the Session event Authentication Challenge, but the project name is not the correct ![]()
but I'm not sure this event works with normal loggin...
Yeah I will try to add a change script on the user id and see what's going to happend ![]()
Why a change script ?
Just bind on the current user's roles.
If you want to check for a particular role, add a script transform:
return "your_particular_role" in value
I need a change script to set values to a lot of sessisons custom properties.
What I did:
- I Created a session custom property 'Authenticated' and I bind it on the session prop props.auth.authenticated cause you can't add change script on the session props directly (you can do it but it's not working)
- Add a change script on my new custom and did:
if 'myrole' in self.props.auth.user.roles :
self.custom.Matrice.right1= True
self.custom.Matrice.right2= True
self.custom.Matrice.right3= True
self.custom.Matrice.right4= True
self.custom.Matrice.right5= True
.........
This working well, thank all for your answer ![]()
That's a perfectly valid use case for bindings.
