1
Automated Log in to SmarterTrack
Problem reported by Frank Cheung - 8/15/2014 at 3:54 PM
Resolved
With older version of smarterTrack (v7), i am able to use the follow code to perform automatic login to Track.  I can no longer do that with the latest version of Track.
 
This method is also detailed in http://portal.smartertools.com/kb/a2450/automate-user-login-to-smarterstats.aspx for SmarterStats.
 
Any idea?  Is this feature no longer supported?  What is the alternative?
 
<head>
</head>
<body>
<form id="form1" runat="server">
    <!-- Automated SmarterTrack Login fields-->
    <input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink" />
    <input type="hidden" name="loginUsername" id="loginUsername" value="username" />
    <input type="hidden" name="loginPassword" id="loginPassword" value="password" />
    <input type="hidden" name="portalurl" id="portalurl" value="http://xxxx" />
    <script language="javascript" type="text/javascript">
        var f = document.forms[0];
        f.action = f.portalurl.value;
        f['__VIEWSTATE'].name = 'NOVIEWSTATE';
        if(f.portalurl.value != '')
        {
            f.submit();
        }
    </script>
    
    Attempting login to SmarterTrack...<br />
    <br />
</form>
</body>
</html>

19 Replies

Reply to Thread
1
Employee Replied
Employee Post
Hi Frank,
 
A few things will fix the code you posted.
 
Remove the following line or add a null check:
f['__VIEWSTATE'].name = 'NOVIEWSTATE'
f['__VIEWSTATE'] could be null and accessing the name property of a null object will cause the script to crash.
 
Also, you will need to change the name of the login and password properties.
"loginUsername" should be changed to "Username"
"loginPassword" should be changed to "Password"
 
After those changes are made it should start working!
 
Cheers,
Mike
0
Frank Cheung Replied
Hello Mike.
 
Changed the code to following but it doesn't work.  Any idea?  Thanks.
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form id="form1" runat="server">
    <!-- Automated SmarterTrack Login fields-->
    <input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink" />
    <input type="hidden" name="Username" id="Username" value="username" />
    <input type="hidden" name="Password" id="Password" value="password" />
    <input type="hidden" name="portalurl" id="portalurl" value="http://xxxx" />
    <script language="javascript" type="text/javascript">
        var f = document.forms[0];
        f.action = f.portalurl.value;
        if(f.portalurl.value != '')
        {
            f.submit();
        }
    </script>
    
    Attempting login to SmarterTrack...<br />
    <br />
</form>
</body>
</html>
0
User Replied
On the fourth input type, the value for portal url should be the url to your portal ending in /Login.aspx. So, for example, ours would be:

http://portal.SmarterTools.com/Login.aspx

Is that how you have you have it?
0
Frank Cheung Replied
No.  The URL is http://portalURL/Main/Default.aspx
 
From my understanding, the /login.aspx page only take you into the Agent Interface, is that right?  I can't even login from that page with regular user account.
1
Derek Curtis Replied
Employee Post
This is an issue with SmarterTrack. Therefore, I changed this from a Question to a Problem as our developers are working on resolving the issue. It will appear in a future minor release.
Derek Curtis COO SmarterTools Inc. www.smartertools.com
0
User Replied
Automatic login is a feature for both the Management Interface and the Portal. The login.aspx url I mentioned previously is for the Magement Interface, which I thought you were trying to log in to. The other changes I noted were still necessary, but upon further investigation we've identified an error with automatic login on the Portal and we will be fixing that for an upcoming update.
3
Employee Replied
Employee Post
We were able to identify and fix this issue before todays minor release.
0
Frank Cheung Replied
Hello Guys.
 
I updated to the latest version.
 
My current code still doesn't work
 
<form id="form1" runat="server">
    <!-- Automated SmarterTrack Login fields-->
    <input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink" />
    <input type="hidden" name="username" id="username" value="username" />
    <input type="hidden" name="password" id="password" value="password" />
    <input type="hidden" name="portalurl" id="portalurl" value="http://portalurl/main/default.aspx" />
    <script language="javascript" type="text/javascript">
        var f = document.forms[0];
        f.action = f.portalurl.value;
        f['__VIEWSTATE'].name = 'NOVIEWSTATE';
        if(f.portalurl.value != '')
        {
            f.submit();
        }
    </script>
    
    Attempting login to SmarterTrack...<br />
    <br />
</form>
0
User Replied
The line:
f['__VIEWSTATE'].name = 'NOVIEWSTATE';
needs to be removed. It's causing an error that is preventing the rest of the script from running.
0
Frank Cheung Replied
Hello Mike.

Removed that line, still no go.
0
User Replied
What are you seeing when it attempts to log in? Are you just seeing the "Attempting to login to SmarterTrack..." message or is it redirecting to your portal yet not logging in a user?

If it is not redirecting, open the development console on your browser (typically by pressing F12) and see if you notice a red X with a number next to it. If you see that, it may mean that there are other javascript errors on the site that could prevent the script from running. You should be able to click the red X for more details. If you're unsure of what you're seeing, feel free to upload a screenshot of it.
0
Frank Cheung Replied
Mike.

It redirects me to Track's page, but i am not logged in.
0
Frank Cheung Replied
i can send you the complete code and a video via email (or ticket if you preferred)
0
User Replied
Well, I may see the issue right away. Is your code replacing the values on these two lines with a valid username and password?

<input type="hidden" name="username" id="username" value="username" />
<input type="hidden" name="password" id="password" value="password" />
0
Frank Cheung Replied
Yes it is. I modified it for the post for security reasons.

The page is actually an aspx page and the uid / password / portal url is dynamically modified depending on the logged in user.

Note that this has worked for the past 5 years.
0
Frank Cheung Replied
If you have a working sample, i don't mind creating a simple test page.
0
User Replied
I'm actually using the code you provided as my working sample right now. My user is admin, password is pass123, and base URL for my local copy of SmarterTrack is simply localhost. I open the following code in a browser as a .html file and it logs me in the Portal. Here is what I have:

<form id="form1" runat="server">
<!-- Automated SmarterTrack Login fields-->
<input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink" />
<input type="hidden" name="username" id="username" value="admin" />
<input type="hidden" name="password" id="password" value="pass123" />
<input type="hidden" name="portalurl" id="portalurl" value="http://localhost/main/default.aspx" />
<script language="javascript" type="text/javascript">
var f = document.forms[0];
f.action = f.portalurl.value;
if(f.portalurl.value != '')
{
f.submit();
}
</script>

Attempting login to SmarterTrack...<br />
<br />
</form>
0
Frank Cheung Replied
Mike.. figured out the problem. The issue is with "runat=server" line. For some reason, asp.net is not populating the values when the runat="server" is present. This is what we have in production now and its working properly. No idea why it doesn't work with the new version.

Anyway, all is good now.

Thanks for your help.
0
User Replied
Sure thing! Glad to hear you have it up and running now!

Reply to Thread