示例#1
0
        private async Task <CustomerInfromationFromToken> customerInfo()
        {
            var info = new CustomerInfromationFromToken
            {
                UserId   = Convert.ToInt32(((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.Sid).Value),
                Country  = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.Country).Value,
                FullName = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.Name).Value,
                UserName = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.NameIdentifier).Value,
            };

            return(info);
        }
示例#2
0
        public async Task <CustomerInfromationFromToken> ValidateUser(string userName, string password)
        {
            using (var uow = this.unitOfWorkFactory.GetUnitOfWork())
            {
                var loginData = await uow.Repository <User>().Query().Select().FirstOrDefaultAsync(a =>
                                                                                                   a.UserName == userName && a.UserPassword == password);

                if (loginData == null)
                {
                    return(new CustomerInfromationFromToken());
                }
                CustomerInfromationFromToken response = new CustomerInfromationFromToken
                {
                    UserName    = loginData.UserName,
                    Country     = loginData.Country,
                    FullName    = loginData.FullName,
                    PhoneNumber = loginData.PhoneNumber,
                    State       = loginData.State,
                    UserId      = loginData.Id
                };
                return(response);
            }
        }