예제 #1
0
        public AuthUser AuthorizeUser(string UserName, string Password)
        {
            if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Password))
            {
                throw new Exception("UserName or Password cannot be null and empty");
            }
            IList <FrameworkUser> UserList = null;

            UserList = _userDataAccess.getUserList(UserName);



            if (UserList != null && UserList.Count > 0 && UserList[0].Password.ToString() == Encryption.EncryptionManager.BasicEncrypt(Password))
            {
                _userDataAccess.AuditLogin(UserName);
                var          menuList      = _userDataAccess.getMenuItem(UserName, Password);
                Subscription cSubscription = new Subscription();
                return(new AuthUser
                {
                    Email = UserList[0].PrimaryEmail,
                    FullName = UserList[0].FirstName + " " + UserList[0].LastName,
                    LastLoginDt = UserList[0].LastLoginDt,
                    Password = Encryption.EncryptionManager.BasicDecrypt(UserList[0].Password),
                    UserName = UserList[0].UserName,
                    CompanyID = UserList[0].CompanyID,
                    CompanyName = UserList[0].CompanyName,
                    PhoneNumber = UserList[0].PrimaryPhone,
                    UserType = UserList[0].UserType,
                    Subscription = new Subscription()
                    {
                        MemberSince = UserList[0].MemberSince,
                        ValidTill = UserList[0].ValidTill,
                        PlanDetail = UserList[0].PlanDetail
                    },
                    Menu = menuList
                });
            }
            return(null);
        }