# Howto login Perspective Session using own login screen

**URL:** <https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068>\
**Category:** Ignition\
**Tags:** ignition80, scripting, perspective\
**Created:** [October 14, 2019, 1:07pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068 "2019-10-14T13:07:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiasatats](https://avatars.discourse-cdn.com/v4/letter/t/ce7236/32.png) [@tobiasatats](https://forum.inductiveautomation.com/u/tobiasatats)\
**Post date:** [October 14, 2019, 1:07pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/1 "2019-10-14T13:07:13Z")

</div>

hi there,

I’d like to log into my perspective session via custom made page. so far the login works, but it won’t authenticate against ignition. So, when I try to open a view with “View Permissions” it won’t give acess.  
I try pushing the user data into the session auth data part. Mayby that’s not meant to be?

so the setup is:

- dropdown for a assembly line
- user dropdown for every user that is allowed for this line (by user role/no need to type)
- login button with onClick event script:

```auto

	success = system.security.validateUser(username, password, "default")

	if success:
		logger.info("Successful user login detected: %s."%(username))
		self.getSibling("Label LoginFailed").props.text= ""
		
		#set user auth in session props (with user object)
		user = system.user.getUser("default", username)
		
		self.session.props.auth.authenticated = True
		self.session.props.auth.user.id = str(user.id)
		self.session.props.auth.user.userName = username
		self.session.props.auth.user.firstName	= user.get(user.FirstName)
		self.session.props.auth.user.lastName = user.get(user.LastName)

		if user.getContactInfo().isEmpty() == False:
			email = user.getContactInfo()[0]	
			self.session.props.auth.user.email = str(email).split(":")[1]
		self.session.props.auth.user.roles = user.roles
	
		# load view
		system.perspective.navigate(page="lineStopOverview")
		system.perspective.openDock("TopDock") #"Docked Windows/North Dock Navigation")		
	
	else:
		self.getSibling("Label LoginFailed").props.text= "Login failed"

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 9, 2021, 8:42pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/2 "2021-02-09T20:42:09Z")

</div>

Pretty sure all of those auth fields are strictly read-only, otherwise what’s the point in having security of all someone needs to do to login is to overwrite some fields. What we need is a login scripting function which is missing.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 9, 2021, 8:44pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/3 "2021-02-09T20:44:22Z")

</div>

> [@nminchin](#):
>
> What we need is a login scripting function which is missing.

I don't think it's missing, it's just not fundamentally compatible with the IDP-based authentication model.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 9, 2021, 8:47pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/4 "2021-02-09T20:47:07Z")

</div>

I figured at was the case. So this means we can’t provide our own login buttons. Will you guys add auto login on launch at some stage? Or should we adopt a new philosophy of using the non auth state for that?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 9, 2021, 8:52pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/5 "2021-02-09T20:52:24Z")

</div>

If you require auto-login on launch, then you should configure the project to require authentication.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 9, 2021, 8:58pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/6 "2021-02-09T20:58:17Z")

</div>

Can we auto login a user at launch though at the moment?

---

<div class="post-metadata">

**Author:** ![jspecht](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jspecht/32/6465_2.png) [@jspecht](https://forum.inductiveautomation.com/u/jspecht)\
**Post date:** [February 10, 2021, 2:12am UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/7 "2021-02-10T02:12:51Z")

</div>

> [@nminchin](#):
>
> What we need is a login scripting function which is missing.

There does exist a [system.perspective.login](https://docs.inductiveautomation.com/display/DOC81/system.perspective.login) scripting function. Invoking it will redirect the browser to the IdP's login page, where the user may enter their credentials (if required), and upon completion, the IdP will redirect the user back to the Perspective page they were on before the login was triggered.

Correct me if I am wrong, but looking at the original post and some of the replies in this thread, it seems like there is a desire to bypass the IdP system altogether and build and embed a custom login page within Perspective itself using the user source profile system. While it's possible to build the pages and views in Perspective and to trigger scripting functions to validate the credentials against a user source, Perspective's security model is built upon Identity Providers and Security Levels, and so it is not possible to coerce a Perspective session into setting the authenticated user and security levels yourself (they may only be set by the system when it processes a valid IdP response and sends it through the relevant attribute mappers, user grants, and security level rules defined on the IdP). As mentioned above, the `session.props.auth.*` session props are essentially "read-only" and managed by the system itself.

> [@nminchin](#):
>
> Can we auto login a user at launch though at the moment?

Could you clarify what you mean by this? Are you looking for a Perspective-analogue to the Auto Login feature in Vision (designer project properties settings shown below)?

 ![Screen Shot 2021-02-09 at 5.57.39 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/c/cc3fc12ccc683813e1c07761fecae0183449936e.png)

If that's the case, the pattern in Perspective is to disable the Authentication requirement at the Project level, which is accomplished by _not_ strictly requiring a security level in the `Authenticated` tree in `Designer > Project Properties > Perspective > Permissions`. This will allow the user to startup the project without logging in, which is effectively the same as "auto-login" using hard-coded credentials, except the user doesn't take on the username of the hard-coded user, but is instead treated as anonymous or unauthenticated. Then, if you want to protect certain script actions or views with authentication, [you can set their respective security level permissions in their designer configurations](https://docs.inductiveautomation.com/display/DOC81/Security+in+Perspective).

If you are looking for something else, please elaborate, we'd like to better understand what that is. There may even already be an idea in the ideas portal submitted for it.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 10, 2021, 2:21am UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/8 "2021-02-10T02:21:47Z")

</div>

Oops, I was thinking about `system.security.validateUser` when I said it was incompatible with the IDP model.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 10, 2021, 2:45am UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/9 "2021-02-10T02:45:13Z")

</div>

> [@jspecht](#):
>
> Are you looking for a Perspective-analogue to the Auto Login feature in Vision (designer project properties settings shown below)?

Correct, this is what I was referring to. What you said RE not requiring login makes sense, it's just a bit of a mentality shift. Really, there's no point in having a particular user automatically logged in to enable access to certain areas or functions as it defeats the purpose of having a user login. I don't really know why I would set it up like that originally to be honest; old habits die hard..

---

<div class="post-metadata">

**Author:** ![Shraddha\_Rathod](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Shraddha\_Rathod](https://forum.inductiveautomation.com/u/Shraddha_Rathod)\
**Post date:** [January 23, 2023, 9:01am UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/10 "2023-01-23T09:01:54Z")

</div>

system.perspective.logout() while using this ...it goes to default login page  
but i require to go to custom login page

how did you resolve this issue ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 23, 2023, 12:49pm UTC](https://forum.inductiveautomation.com/t/howto-login-perspective-session-using-own-login-screen/29068/11 "2023-01-23T12:49:32Z")

</div>

You create your own standards-compliant Identity Provider **outside of Ignition**. Configure Ignition to use it for your project.
