Ejemplo n.º 1
0
        public LoginReturnDTO Login(LoginInfoDTO loginInfo)
        {
            LoginReturnDTO lrd = new LoginReturnDTO();

            User user = uow.UserRepository.GetByUsername(loginInfo.Username);

            if (user == null)
            {
                lrd.IsSuccess = false;
                lrd.Message   = "Username and/or password are incorect";
            }
            else if (user.Blocked)
            {
                lrd.IsSuccess = false;
                lrd.Message   = "Account is blocked by administrator";
            }
            else if (user.Password.Equals(loginInfo.Password))
            {
                lrd.IsSuccess = true;
                lrd.User      = user;
                lrd.Message   = "Success";


                UserPrincipal principal = new UserPrincipal(user, true);
                SetPrincipal(principal);
            }

            return(lrd);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="acnt"></param>
        /// <param name="pwd"></param>
        public static LoginReturnInfoDTO Login(string acnt, string pwd)
        {
            LoginReturnInfoDTO returnInfo = null;

            LoginInfoDTO InfoDTO = new LoginInfoDTO();

            InfoDTO.AccountType = AccountTypeEnum.Anonymous;
            InfoDTO.IuAccount   = acnt;
            InfoDTO.IuPassword  = pwd;
            UserFacade userFacade = new UserFacade();

            try
            {
                UserFacade userManage = new UserFacade();
                returnInfo = userFacade.Login(InfoDTO);
                //将用户登录成功后返回的上下文信息放入当前Session中保存起来,以便用户下次访问非登录页面时能取到Context对象
                return(returnInfo);
            }
            catch (Exception ex)
            {
                string msg = string.Format("AuthorizeHelper.Login异常,异常信息:{0}", ex);
                LogHelper.Error(msg);

                returnInfo           = new LoginReturnInfoDTO();
                returnInfo.IsSuccess = false;
                returnInfo.Message   = "登录异常";
                return(returnInfo);
            }
        }
Ejemplo n.º 3
0
        public ActionResult AdminLogin(LoginInfoDTO account)
        {
            string encryptpass = MD5Helper.MD5Encrypt(account.PassWord);

            using (var userDal = new UserDAL())
            {
                var AccountInfo = userDal.GetUserByUserNameAndPasswordForAdmin(account.UserName, encryptpass, true);
                if (AccountInfo == null)
                {
                    ModelState.AddModelError("WrongPassword", "Sai mật khẩu hoặc tài khoản không tồn tại!");
                }
                else if (!AccountInfo.IsActive || !AccountInfo.IsVerify)
                {
                    ModelState.AddModelError("LockedAccount", "Tài khoản bị khóa hoặc chưa xác nhận Email!");
                }
                //Updated Logged time for account.
                else
                {
                    AccountInfo.LastLogin = DateTime.Now;
                    userDal.UpdateUser(AccountInfo);
                    //FormsAuthentication.SetAuthCookie(AccountInfo.UserName, false);
                }
                //Add remember me


                //return RedirectToAction("DashBoard", "Admin");
                return(Redirect("/Admin/#/DashBoard"));
            }
        }
Ejemplo n.º 4
0
        private AuthResult KeyLogin(User user, LoginInfoDTO loginInfoDTO, IUOW Data)
        {
            KeyStatus keyStatus;

            if (user.authType == AuthType.Email)
            {
                keyStatus = EmailAuthService.Check(user.Email, loginInfoDTO.Key, Data);
            }
            else if (user.authType == AuthType.Phone)
            {
                keyStatus = PhoneAuthService.Check(user.Phone, loginInfoDTO.Key, Data);
            }
            else
            {
                throw new UserAuthException(AuthError.AuthTypeNotFound);
            }
            if (keyStatus == KeyStatus.Success)
            {
                return new AuthResult {
                           Status = AuthStatus.Succsess, Identity = ClaimService.Generate(user, Data, loginInfoDTO)
                }
            }
            ;
            else if (keyStatus == KeyStatus.KeyTimeEnded)
            {
                return new AuthResult {
                           Status = AuthStatus.NeedNewKey
                }
            }
            ;
            return(new AuthResult {
                Status = AuthStatus.WrongKey
            });
        }
        public bool ValidateLogin(LogInInfo loginInfo)
        {
            LoginInfoDTO loginInfoDTO = new LoginInfoDTO();

            loginInfoDTO.Username = loginInfo.Username;
            loginInfoDTO.Password = loginInfo.Password;

            try
            {
                patientInfoDTO = API.GetObject <PatientInfoDTO, LoginInfoDTO>("PatientLogin", loginInfoDTO);
            }
            catch (WebException e) when((e.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound)
            {
                Console.WriteLine(e);
            }

            if (patientInfoDTO.CPR != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Login([FromBody] LoginInfoDTO model)
        {
            if (ModelState.IsValid)
            {
                return(await AuthorizeResultAsync(model, StatusCodes.Status200OK));
            }

            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the Prize Information for the player
        /// </summary>
        /// <param name="AccountNumber"></param>
        /// <returns>List of prizes available</returns>
        public List <PrizeInfoDTO> GetPrizeInfo(string AccountNumber)
        {
            List <PrizeInfoDTO> listPrizeInfo = new List <PrizeInfoDTO>();

            try
            {
                LoginInfoDTO loginInfoDTO = GetLoginInformation();
                serviceResult = kioskService.EmployeeLogin(loginInfo);

                if (MethodResult.Success == serviceResult.Result)
                {
                    loginInfo.LocationCode    = serviceResult.Data[0].ToString();
                    loginInfoDTO.LocationCode = serviceResult.Data[0].ToString();
                    DateTime gamingdate = DateTime.Today;
                    if (true == DateTime.TryParse(serviceResult.Data[1].ToString(), out gamingdate))
                    {
                        loginInfo.GamingDate    = gamingdate;
                        loginInfoDTO.GamingDate = gamingdate;
                    }
                    else
                    {
                        loginInfo.GamingDate    = DateTime.Today;
                        loginInfoDTO.GamingDate = DateTime.Today;
                    }

                    loginInfo.Shift    = int.Parse(serviceResult.Data[2].ToString());
                    loginInfoDTO.Shift = int.Parse(serviceResult.Data[2].ToString());
                }
                PrizeInfo[]         PrizeInfoTbl   = kioskService.RetrievePriceList(AccountNumber, loginInfo);
                List <PrizeInfoDTO> prizeInfoArray = new List <PrizeInfoDTO>();

                foreach (PrizeInfo item in PrizeInfoTbl)
                {
                    PrizeInfoDTO PrizeInfoObject = new PrizeInfoDTO();
                    PrizeInfoObject.AuthAward    = item.AuthAward.ToString();
                    PrizeInfoObject.AwardUsed    = item.AwardUsed.ToString();
                    PrizeInfoObject.BasePoints   = item.BasePoints.ToString();
                    PrizeInfoObject.BonusPoints  = item.BonusPoints.ToString();
                    PrizeInfoObject.PrizeId      = item.PrizeId;
                    PrizeInfoObject.PrizeName    = item.PrizeName;
                    PrizeInfoObject.RedeemPoints = item.RedeemPoints.ToString();
                    prizeInfoArray.Add(PrizeInfoObject);
                }

                foreach (PrizeInfoDTO objPrizeInfo in prizeInfoArray)
                {
                    listPrizeInfo.Add(objPrizeInfo);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return(null);
            }
            return(listPrizeInfo);
        }
Ejemplo n.º 8
0
        public async Task <LoginResponce> LogInOffline(string name, string password)
        {
            string result  = String.Empty;
            bool   success = false;

            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            try {
                if (sqliteService != null)
                {
                    LoginInfoDTO currentLoginInfo = new LoginInfoDTO();
                    currentLoginInfo.UserName = name;
                    currentLoginInfo.Password = SecurytyHash.CalculateSha1Hash(password);
                    result = _localizservice.Localize("NotSavedDataOffline");
                    List <LoginInfoDTO> listlogins = await sqliteService.Get <LoginInfoDTO>();

                    if (listlogins != null && listlogins.Count != 0)
                    {
                        foreach (LoginInfoDTO login in listlogins)
                        {
                            if (login.UserName == currentLoginInfo.UserName)
                            {
                                result = string.Empty;
                                if (login.Password == currentLoginInfo.Password)
                                {
                                    success = true;
                                    result  = string.Empty;
                                }
                                else
                                {
                                    result = _localizservice.Localize("IncorrectLoginOrPassword");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result  = String.Format("Error = " + e.Message);
                success = false;
            }
            return(await Helper.Complete(new LoginResponce(success, result)));
        }
Ejemplo n.º 9
0
        private UserClaim GenerateClaim(User user, LoginInfoDTO loginInfoDTO)
        {
            var now   = DateTime.Now;
            var claim = new UserClaim {
                LoginBrowser = loginInfoDTO.Browser,
                User         = user,
                LoginTime    = DateTime.Now,
                LoginIp      = loginInfoDTO.IP
            };

            claim.Value = user.Login + "-" + now.ToString();
            return(claim);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Get Login Information for the player
        /// </summary>
        ///
        /// <returns>Login information for the player</returns>
        ///
        public LoginInfoDTO GetLoginInformation()
        {
            Dictionary <string, string> CMPDetails = playerInformationDataAccess.GetCMPCredentials(CommonDataAccess.ExchangeConnectionString);

            loginInfo = new LoginInfo();
            loginInfo.ComputerName = Environment.MachineName;

            loginInfo.GamingDate = new DateTime(2001, 01, 01, 0, 0, 0);

            loginInfo.LocationCode = null;
            loginInfo.Password     = CMPDetails["CMPPWD"];
            loginInfo.Shift        = 1;
            loginInfo.UserName     = CMPDetails["CMPUSER"];

            if (CMPDetails.Count > 0)
            {
                kioskService = new KioskService(CMPDetails["CMPURL"].ToString());
            }

            serviceResult = kioskService.EmployeeLogin(loginInfo);

            if (MethodResult.Success == serviceResult.Result)
            {
                loginInfo.LocationCode = serviceResult.Data[0].ToString();
                DateTime gamingdate = DateTime.Today;
                if (true == DateTime.TryParse(serviceResult.Data[1].ToString(), out gamingdate))
                {
                    loginInfo.GamingDate = gamingdate;
                }
                else
                {
                    loginInfo.GamingDate = DateTime.Today;
                }

                loginInfo.Shift = int.Parse(serviceResult.Data[2].ToString());
            }

            List <LoginInfoDTO> LoginInfoList = new List <LoginInfoDTO>();


            LoginInfoDTO loginInfoDTO = new LoginInfoDTO();

            loginInfoDTO.ComputerName = loginInfo.ComputerName;
            loginInfoDTO.GamingDate   = loginInfo.GamingDate;
            loginInfoDTO.LocationCode = loginInfo.LocationCode;
            loginInfoDTO.Password     = loginInfo.Password;
            loginInfoDTO.Shift        = loginInfo.Shift;
            loginInfoDTO.UserName     = loginInfo.UserName;
            return(loginInfoDTO);
        }
Ejemplo n.º 11
0
 public Jinher.AMP.CBC.Deploy.CustomDTO.LoginReturnInfoDTO Login(LoginInfoDTO loginInfoDTO)
 {
     Jinher.AMP.CBC.Deploy.CustomDTO.LoginReturnInfoDTO loginInfoDT = null;
     try
     {
         Jinher.AMP.CBC.ISV.Facade.UserFacade userFacade = new CBC.ISV.Facade.UserFacade();
         //userFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
         loginInfoDT = userFacade.Login(loginInfoDTO);
     }
     catch (Exception ex)
     {
         LogHelper.Error(string.Format("CBCSV.Login服务异常:获取应用信息异常。 loginInfoDTO:{0}", loginInfoDTO), ex);
     }
     return(loginInfoDT);
 }
Ejemplo n.º 12
0
        private async Task <IActionResult> AuthorizeResultAsync(LoginInfoDTO model, int code)
        {
            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                var result = await _signInManager.PasswordSignInAsync(user, model.Password, model.RememberMe, true);

                if (result.Succeeded)
                {
                    return(StatusCode(code, await MapToProfile(user)));
                }
            }

            return(Unauthorized());
        }
Ejemplo n.º 13
0
        // 用户登录认证
        public static LoginInfoDTO Login(string UserName, string PassWord)
        {
            string strUserName = "******" + UserName;
            string strPassWord = "******" + PassWord;
            string strSuffix   = "&grant_type=password&client_id=toptimus_client&client_secret=123456";
            string url         = XindianAppConfig.businessServiceUri + "/oauth/token" + strUserName + strPassWord + strSuffix;
            string rv          = RestCall.PostHttp(url, "");

            if (string.IsNullOrEmpty(rv))
            {
                return(null);
            }

            LoginInfoDTO ret = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginInfoDTO>(rv);

            return(ret);
        }
Ejemplo n.º 14
0
        public AuthResult Login(LoginInfoDTO loginInfoDTO)
        {
            using (var Data = DataFactory.Get())
            {
                User user = GetUser(loginInfoDTO.Login, loginInfoDTO.Password, Data);
                if (user == null)
                {
                    return new AuthResult {
                               Status = AuthStatus.UserNotFound
                    }
                }
                ;
                if (user.Ban != null)
                {
                    if (user.Ban.EndTime < DateTime.Now)
                    {
                        return new AuthResult {
                                   Status = AuthStatus.UserBanned, KeyTime = user.Ban.EndTime, Comment = user.Ban.Reason
                        }
                    }
                    ;
                    else
                    {
                        Data.BanRepository.Delete(user.Ban);

                        Data.SaveChanges();
                    }
                }
                if (user.authType == AuthType.Simple)
                {
                    return new AuthResult {
                               Status = AuthStatus.Succsess, Identity = ClaimService.Generate(user, Data, loginInfoDTO)
                    }
                }
                ;
                else if (!String.IsNullOrEmpty(loginInfoDTO.Key))
                {
                    return(KeyLogin(user, loginInfoDTO, Data));
                }
                else
                {
                    return(SendKey(user, Data));
                }
            }
        }
Ejemplo n.º 15
0
        //---------------------------------------------------
        public ClaimsIdentity Generate(User user, IUOW Data, LoginInfoDTO loginInfoDTO)
        {
            if (user == null || loginInfoDTO == null)
            {
                return(null);
            }
            var claim = GenerateClaim(user, loginInfoDTO);

            Data.UserClaimRepository.Add(claim);
            Data.SaveChanges();
            var claims = new List <Claim>
            {
                new Claim(ClaimNames.UserID, user.Id.ToString()),
                new Claim(ClaimNames.SessionID, claim.Id.ToString()),
                new Claim(ClaimNames.SessionValue, claim.Value.ToString()),
            };

            return(new ClaimsIdentity(claims, "ApplicationCookie"));
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Register([FromBody] LoginInfoDTO model)
        {
            if (ModelState.IsValid)
            {
                var user = new User {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRolesAsync(user, new[] { "User" });

                    return(await AuthorizeResultAsync(model, StatusCodes.Status200OK));
                }
            }

            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
Ejemplo n.º 17
0
        public async Task SaveLoginModelToSQLite(string name, string password)
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    LoginInfoDTO currentLoginInfo = new LoginInfoDTO();
                    currentLoginInfo.UserName = name;
                    currentLoginInfo.Password = SecurytyHash.CalculateSha1Hash(password);

                    List <LoginInfoDTO> listlogins = await sqliteService.Get <LoginInfoDTO>();

                    if (listlogins != null && listlogins.Count != 0)
                    {
                        foreach (LoginInfoDTO login in listlogins)
                        {
                            if (login.UserName == currentLoginInfo.UserName)
                            {
                                await sqliteService.Delete <LoginInfoDTO>(login.Id.ToString());
                            }
                        }
                    }

                    await sqliteService.Insert <LoginInfoDTO>(currentLoginInfo);
                }
                catch (Exception ex)
                {
                }
            }
        }
        private void btnRedeem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Cursor = Cursors.Wait;
                if (Settings.IsKioskRequired)
                {
                    if (lblUnitPointValue.Content.ToString().Length > 0 && int.Parse(lblUnitPointValue.Content.ToString()) > 0 && txtPrizeQty.Text.Length > 0 && int.Parse(txtPrizeQty.Text) > 0)
                    {
                        LoginInfoDTO       objLoginInfo        = playerInformationBusinessObject.GetLoginInformation();
                        PlayerInfoDTO      objPlayerInfo       = playerInformationBusinessObject.GetPlayerInformation(txtAcctNo.Text);
                        IPlayerInformation objCashDeskOperator = PlayerInformationBusinessObject.CreateInstance();
                        if (objCashDeskOperator.UpdateRedeempoints(txtAcctNo.Text, listReedeem.PrizeId, int.Parse(txtPrizeQty.Text),
                                                                   int.Parse(listReedeem.RedeemPoints), objLoginInfo, objPlayerInfo) == true)
                        {
                            if (objCashDeskOperator.CheckEnableRedeemPrintCDO() == true)
                            {
                                EpsonReceiptPrint();
                            }
                            MessageBox.ShowBox("MessageID90", BMC_Icon.Information);

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.PlayerClub,
                                Audit_Screen_Name  = "PlayerClub",
                                Audit_Desc         = "Player club points redeemed",
                                AuditOperationType = OperationType.ADD,
                                Audit_Field        = "Reedeem Points",
                                Audit_New_Vl       = listReedeem.RedeemPoints
                            });

                            LoadPlayerInfo();
                            lblUnitPointValue.Content = listReedeem.RedeemPoints;
                            lblCashValue.Content      = listReedeem.AuthAward;
                            txtPrizeQty.Text          = "1";
                        }
                        else
                        {
                            MessageBox.ShowBox("MessageID91", BMC_Icon.Information);

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.PlayerClub,
                                Audit_Screen_Name  = "PlayerClub",
                                Audit_Desc         = "Unable to redeem points",
                                AuditOperationType = OperationType.ADD,
                            });
                        }
                    }
                    else if (txtAcctNo.Text == "0" || txtAcctNo.Text == "")
                    {
                        MessageBox.ShowBox("MessageID92", BMC_Icon.Information);
                    }
                    else if (txtPrizeQty.Text.Length <= 0)
                    {
                        MessageBox.ShowBox("MessageID93", BMC_Icon.Information);
                        txtPrizeQty.Text = "1";
                    }
                    else if (int.Parse(txtPrizeQty.Text) <= 0)
                    {
                        MessageBox.ShowBox("MessageID93", BMC_Icon.Information);
                        txtPrizeQty.Text = "1";
                    }
                    else if (txtAcctNo.Text != "")
                    {
                        LoadPlayerInfo();
                    }
                }

                else
                {
                    MessageBox.ShowBox("MessageID376", BMC_Icon.Information);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.ShowBox("MessageID94", BMC_Icon.Information);
                txtPrizeQty.Text = "1";
                ExceptionManager.Publish(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Update the current balance with points redeemed.
 /// </summary>
 /// <param name="PrizeID"></param>
 /// <param name="PrizeQty"></param>
 /// <param name="strAcctNumber"></param>
 /// <returns >success or failure</returns>
 public bool UpdateRedeempoints(string AcctNumber, string PrizeID, int PrizeQty, int RedeemPoints, LoginInfoDTO loginInfo, PlayerInfoDTO playerInfo)
 {
     return(kiosk.UpdateRedeempoints(AcctNumber, PrizeID, PrizeQty, RedeemPoints, loginInfo, playerInfo));
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Redeem Points for Player.
        /// </summary>
        /// <param name="AccountNumber"></param>
        ///
        /// <returns>List of prizes available</returns>
        public bool UpdateRedeempoints(string AcctNumber, string PrizeID, int PrizeQty, int redeempoints, LoginInfoDTO loginInfo, PlayerInfoDTO playerInfo)
        {
            bool IsReedemed = false;

            try
            {
                Dictionary <string, string> CMPDetails = playerInformationDataAccess.GetCMPCredentials(CommonDataAccess.ExchangeConnectionString);

                if (CMPDetails.Count > 0)
                {
                    kioskService = new KioskService(CMPDetails["CMPURL"].ToString());
                }

                RedeemPrizeInfo redeemPrizeInfo = new RedeemPrizeInfo();
                redeemPrizeInfo.AccountNumber  = AcctNumber;
                redeemPrizeInfo.ComputerName   = Environment.MachineName;
                redeemPrizeInfo.GamingDate     = new DateTime(2001, 1, 1);
                redeemPrizeInfo.LocationCode   = loginInfo.LocationCode;
                redeemPrizeInfo.PrintedRemarks = null;
                redeemPrizeInfo.PrivateRemarks = null;
                redeemPrizeInfo.PlayerId       = playerInfo.PlayerID;
                redeemPrizeInfo.Password       = CMPDetails["CMPPWD"];
                redeemPrizeInfo.Shift          = 1;

                redeemPrizeInfo.UserName = CMPDetails["CMPUSER"];

                if (!String.IsNullOrEmpty(PrizeID))
                {
                    redeemPrizeInfo.PrizeId = PrizeID;
                }
                redeemPrizeInfo.PrizeQty     = PrizeQty;
                redeemPrizeInfo.RedeemPoints = redeempoints * redeemPrizeInfo.PrizeQty;

                ServiceResult objServiceResult = (ServiceResult)kioskService.RedeemPoints(redeemPrizeInfo);

                if (MethodResult.Success == objServiceResult.Result)
                {
                    IsReedemed = true;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                IsReedemed = false;
            }
            return(IsReedemed);
        }