Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: Multiple Integration Logins Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ari123z
Newbie
Newbie


Joined: 17 December 2012
Location: United States
Online Status: Offline
Posts: 8
Posted: 17 December 2012 at 2:27pm | IP Logged Quote ari123z

Hi, I am able to get the integration UserLoginByEmail working initially, but I wrote a system that allows administrators to login /open to different users' webmail from our own admin portal. So AdminA wants to open UserB's webmail, they click a link from our admin portal and open UserB's webmail, opens in new window. no problem. Then they click logout, close the new window that opened and go back and click to open UserC's webmail. It opens in a new window, but the webmail window is still pointing to UserB's webmail. If AdminA closes that window and clicks UserC's webmail link again, then UserC's webmail opens properly, but if AdminA moves to UserD or another user, same issue. Any ideas?
Back to Top View ari123z's Profile Search for other posts by ari123z
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6088
Posted: 17 December 2012 at 10:25pm | IP Logged Quote Igor

While it's possible to log user in programmatically, current API of WebMail Pro (ASP.NET) doesn't have an option to log user out. Thus, the only way here is to destroy the session itself before logging new user in.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
ari123z
Newbie
Newbie


Joined: 17 December 2012
Location: United States
Online Status: Offline
Posts: 8
Posted: 18 December 2012 at 6:55am | IP Logged Quote ari123z

Ok, but your logoff function built into your webmail should do that for me? I tried using it in the context above, but it did not destroy the session properly. Is this just a bug?

Can I propose a log off API function? I hope you could see how this function might be useful to an admin portal such as mine.
Back to Top View ari123z's Profile Search for other posts by ari123z
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6088
Posted: 18 December 2012 at 6:58am | IP Logged Quote Igor

Quote:
Ok, but your logoff function built into your webmail should do that for me?


No idea, it was never tested alongside integration API.

Quote:
Can I propose a log off API function? I hope you could see how this function might be useful to an admin portal such as mine.


Sure, if you find a working solution, we'll post it in the documentation for other users.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
ari123z
Newbie
Newbie


Joined: 17 December 2012
Location: United States
Online Status: Offline
Posts: 8
Posted: 18 December 2012 at 9:32am | IP Logged Quote ari123z

I figured it out. The integration script just creates a hash based on the session-id and stores it in a temporary table so that when the integr.aspx is called, it reads the account id using the session-id hash, logs the user in and then deletes the key from the temporary table. That should work fine in my instance, but for some reason the hash isn't always deleted properly and when I click to login another user it goes and creates another temporary key with the same hash so integr.aspx just grabs the first one and logs in the original user.

I don't know exactly what the issue is, but I basically changed UserLoginByEmail function in Integration.cs to the following, deleting all temporary keys with current session-id hash prior to creating any new ones. I consider this a bug and hope it will be merged / fixed properly in future editions.

public void UserLoginByEmail(string email, string login, string password, WMStartPage startPage, string toEmail)
          {
               Account acct = Account.LoginAccount(email, login, password);
               if (acct != null)
               {
                    string sessionHash = Utils.GetMD5DigestHexString(HttpContext.Current.Session.SessionID);
                    DbStorage storage = DbStorageCreator.CreateDatabaseStorage(acct);
                    TempRow tempRow = null;
                    DbStorage tempStorage = DbStorageCreator.CreateDatabaseStorage(null);
                    try {
                         tempStorage.Connect();
                         tempRow = storage.GetTempRow(-1, string.Format(@"sessionHash_{0}", sessionHash));
                         if (tempRow != null) {
                              storage.DeleteTempRo w(tempRow.ID);
                         }
                    } catch (Exception ex) {
                         Log.WriteException(ex);
                    } finally {
                         tempStorage.Disconnect();
                    }
                    try
                    {
                         storage.Connect();
                         storage.CreateTempRow(acct.ID, string.Format(@"sessionHash_{0}", sessionHash));
                    }
                    catch (WebMailException)
                    {
                         throw;
                    }
                    catch (Exception ex)
                    {
                         throw new WebMailDatabaseException(ex);
                    }
                    finally
                    {
                         storage.Disconnect();
                    }

               HttpContext.Current.Response.Redirect(_wmRoot + @"/" + string.Format(@"integration/integr.aspx?hash={0}&scr={1}&to={2}", sessionHash, (int)startPage, toEmail), false);
            }
          }
Back to Top View ari123z's Profile Search for other posts by ari123z
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6088
Posted: 19 December 2012 at 12:35am | IP Logged Quote Igor

Thanks for the update. I've asked the developers to look at this code, and they confirm it should work as expected; we haven't tested this ourselves though.

We're not planning new releases of WebMail Pro ASP.NET in the near future, but if other users face the same problem we'll point them to tis forum thread - and to the relevant documentation page once it's added there.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide