I have these files:
Application.cfc:
Onrequeststart method:
session.remoteuser = cgi.REMOTE_USER
Based on the this user, the view is: Admin view or user view
I have index.cfm
<div ng-app controller>
</div>
Angular code replaces the view here.
But from admin view i want to create a form which changes the session.remoteuser
to any user they want to view as. I created a form in adminview.cfm
page and checking to see if the form is submitted in application.cfc
. But I see application.cfc
is fired twice so the view is getting the user id, but goes back to admin id. How do I achieve this ?
To continue to set the session.remoteuser
variable in OnRequestStart()
, structure your logic like this.
if the form variable exists
set `session.remoteuser` accordingly
else if `session.remoteuser` does not exist
set `session.remoteuser` to cgi.remoteUser
else
do nothing
Then, when the admin person loads the form page, session.remoteuser
will be set to that person. It will change when the form is submitted and will not change again for the rest of the session unless there is a way to access the form page again when your application thinks he's the person selected in the form.