예제 #1
0
        public static M2ESession getSessionInfo(string sessionId, HeaderManager headers)
        {
            M2ESession session = null;
            if (IsValidSession(sessionId, out session))
            {
                return session;
            }
            else
            {
                if (headers == null)
                    return null;
                if (sessionId == null)
                    return null;
                string Authkey = ConfigurationManager.AppSettings["AuthKey"];                

                string username = EncryptionClass.GetDecryptionValue(headers.AuthKey, Authkey);
                M2EContext _db = new M2EContext();
                var dbUserInfo = _db.Users.SingleOrDefault(x=>x.Username == username);
                if (dbUserInfo != null)
                {
                    var data = new Dictionary<string, string>();                    
                    data["Password"] = headers.AuthValue;
                    data["userGuid"] = dbUserInfo.guid;

                    try
                    {
                        var decryptedData = EncryptionClass.decryptUserDetails(data);

                        if (dbUserInfo.KeepMeSignedIn == "true" && dbUserInfo.Password == decryptedData["UTMZV"])
                        {
                            var NewSession = new M2ESession(username, sessionId);
                            TokenManager.CreateSession(NewSession);
                            return getSessionInfo(sessionId, headers);
                        }
                        else
                        {
                            return null;
                        }

                    }
                    catch (Exception)
                    {

                        return null;
                    }
                    

                }
                else
                {
                    return null;
                }                
            }
        }