Exemplo n.º 1
0
        public ApiLoginUserResponse LoginUser([FromBody] ApiLoginRequest uf)
        {
            var apiResp = new ApiLoginUserResponse {
                ResponseType = -1, ResponseMessage = "Failed"
            };

            var retVal = (new JukeBox.BLL.Account()).LoginUser(uf.username, uf.password);

            // string incomingHash = (new JukeBox.BLL.Account()).HashAndObfuscate(uf.password);

            if (retVal == null)
            {
                apiResp.ResponseMessage = "Invalid Username";
                apiResp.ResponseObject  = null;
                return(apiResp);
            }
            if (!retVal.Password.Equals(uf.password))
            {
                apiResp.ResponseMessage = "Invalid Password";
                apiResp.ResponseObject  = null;
                return(apiResp);
            }
            //check to see if the password is valid
            //if (String.CompareOrdinal(incomingHash, retVal.Password) != 0)
            //{
            //    apiResp.ResponseMessage = "Password invalid";
            //    apiResp.ResponseObject = null;
            //    return apiResp;
            //}

            if (retVal != null)
            {
                var apiLoginUser = new ApiUser();
                apiLoginUser.Bind(retVal);
                apiResp.ResponseObject  = apiLoginUser;
                apiResp.ResponseType    = 1;
                apiResp.ResponseMessage = "Success";
            }
            return(apiResp);
        }