Example #1
0
        public ServiceResponse <Core.Domain.Users> VerifyUser([FromBody] JObject jObject)
        {
            var username     = (string)jObject["Username"];
            var password     = (string)jObject["Password"];
            var deviceNumber = (string)jObject["DeviceNumber"];
            var response     = new ServiceResponse <Core.Domain.Users>();

            try
            {
                var user = _userService.VerifyUser(username, password, deviceNumber);
                if (user != null)
                {
                    var key = _webHelper.Encrypt(user.Id + "@_@" + user.DeviceNumber + "@_@" + DateTime.Now.ToString());
                    this.Response.Headers.Add("ApiKey", key);
                    user.ApiKey      = key;
                    response.Model   = user;
                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = GetErrorMessageDetail(ex);
            }
            return(response);
        }