示例#1
0
        public IActionResult Get([FromHeader] string authorization)
        {
            UserReadDbo user = _auth.ValidateUser(authorization);

            if (user == null)
            {
                return(_auth.GetError());
            }

            IEnumerable <Contact> ret = _repo.GetContacts(user.Id).Select(item => new Contact
            {
                Id              = item.Id,
                Name            = item.Name,
                Description     = item.Description,
                Birthdate       = item.Birthdate?.ToString("yyyy-MM-dd"),
                PrettyBirthdate = item.Birthdate?.ToString("MMMM dd, yyyy"),

                CreatedAt = item.CreatedAt.ToLocalTime().ToString("F"),
                UpdatedAt = item.CreatedAt.ToLocalTime().ToString("F"),

                Favorite = item.Favorite,
                GroupId  = item.GroupId
            });

            return(Ok(ret));
        }
示例#2
0
        public bool ValidateUser(string tenantName, string username, string password)
        {
            if (string.IsNullOrEmpty(tenantName))
            {
                throw new ArgumentNullException("tenantName");
            }
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException("username");
            }
            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            return(AuthenticationLogic.ValidateUser(tenantName, username, password));
        }