Beispiel #1
0
        public async Task <Filer> Login(string emailAddress, string password)
        {
            Filer      retFiler     = null;
            FilerLogin filerRequest = new FilerLogin()
            {
                UserName = emailAddress,
                Password = password
            };

            var filerResponse = await _userServiceWrapper.Login(filerRequest);

            if (filerResponse != null && !string.IsNullOrEmpty(filerResponse.EFMUserId))
            {
                retFiler = await _filerDal.GetAndUpdateFiler(filerResponse.UserName, filerResponse.EFMUserId,
                                                             filerResponse.Password) ?? new Filer
                {
                    EmailAddress = emailAddress,
                    Password     = password
                };
            }

            return(retFiler);
        }
        public async Task <IActionResult> Login(UserDtoParameter user)
        {
            UserInfo userInfo = await _userServiceWrapper.Login(user.UserName, user.Password);

            UserDto returnUserDto = new UserDto();

            if (userInfo?.UserName != null && userInfo.Status == UserInfo.StatusType.正常)
            {
                string myToken = await _tokenServiceWrapper.InsertToTokenAsync(userInfo.UserName, DateTime.Now, DateTime.Now.AddDays(1), "", "", "");

                HttpRequestUserInfo requestUserInfo = _mapper.Map <HttpRequestUserInfo>(userInfo);

                HttpContext.Session.SetString(myToken, JsonSerializer.Serialize(requestUserInfo));
                returnUserDto.MyToken     = myToken;
                returnUserDto.LoginResult = true;
            }
            else
            {
                returnUserDto.LoginResult = false;
            }

            return(Ok(returnUserDto));
        }