Security projet with on perspective

Hello, I want translate this script on my perspective projet.
Somme one can help me?

def onStartup(session):
“”"
Called when a new session is authorized and starts.

Arguments:
	session: A reference to the newly created session
"""
username = system.security.getUsername()
if "admin" == username.lower():
   # Set "guest" user to read-only mode.
   system.util.setConnectionMode(2)
else:
   system.util.setConnectionMode(3)

if this is a copy of you vision, than your vision is not that correct either, you should not validate to usernames, but to userRoles.

in perspective you can get the userRoles (and name i suppose but dont use it) in the session props

self.session.props.auth.user.roles
self.session.props.auth.user.userName

system.util.setConnectionMode() also doesnt exsits in perspective tho.
no idea if there is something that does something similar in perspective

1 Like