Exemple #1
0
        public ActionResult Login(AccountLoginDto dto)
        {
            var accountVerifyInfoDto = _accountService.AccountMatch(dto.AccountName, dto.Password);

            if (accountVerifyInfoDto == null)
            {
                ViewData["errorMsg"] = "账号或者密码错误";

                //账号或者密码错误
                return(View());
            }

            //var webAppKey = RequestUtils.GetString("CacheKey");
            //var callBackUrl = RequestUtils.GetString("CallBackUrl");

            var webAppInfo  = _webAppManager.GetWebAppInfoByCacheKey(dto.CacheKey, dto.CallBackUrl);
            var accountInfo = new AccountInfo(accountVerifyInfoDto.AccountId, accountVerifyInfoDto.Code,
                                              accountVerifyInfoDto.AccountName);

            _logger.Info(accountVerifyInfoDto);
            _logger.Info(accountInfo);

            //写入TGC,因为已经登陆成功,所以此时需要写入,至于Ticket的验证,那是后续的事情
            _ticketGrantingManager.SetTicketGranting(accountInfo);
            //验证,跳转
            var ticket = _ticketManager.CreateTicket(accountInfo.AccountId, accountInfo.Code);
            var url    = UrlUtils.GetClientVerifyTicketUrl(webAppInfo, ticket,
                                                           dto.CallBackUrl);

            return(Redirect(url));
        }