示例#1
0
        public MemberResponse Authenticate(string username, string password)
        {
            var user = _map.Map <MemberResponse>(_unitofwork.GetRepository <Member>()
                                                 .GetFirstOrDefault(predicate: x => x.username == username && x.password == password,
                                                                    ignoreQueryFilters: true));

            if (user == null)
            {
                return(null);
            }
            user.token = _jwtService.GenerateSecurityToken(user);
            user.encryptedCompnayId = _protector.Protect(user.companyid.ToString());
            user.CompanyName        = (_unitofwork.GetRepository <Company>().Find(user.companyid)).title;
            user.companyid          = Guid.Empty;
            return(user.WithoutPassword());
        }