public IActionResult ChangePassword([FromBody] ChangePasswordRequest RequestData)
        {
            if (!_service.IsAuthorizedRiderOrAdmin(
                    RequestData.RequestingId,
                    RequestData.TargetId,
                    RequestData.Authorization))
            {
                return(Unauthorized());
            }


            Rider foundRider = _context.Riders.SingleOrDefault <Rider>(
                r => r.ID == RequestData.TargetId);

            if (foundRider != null)
            {
                AuthorizationResponseData ResponseData = _service.UpdatePassword(foundRider, RequestData.Password);
                return(Ok(ResponseData));
            }

            return(NotFound());
        }
Exemplo n.º 2
0
        public bool IsAuthorizedRiderOrAdmin(int RequestingId, int RiderId, string Authorization)
        {
            return(_riderService.IsAuthorizedRiderOrAdmin(RequestingId, RiderId, Authorization));

            /*
             * bool result = true;
             * if (RequestingId != RiderId)
             * {
             *  if (!this.IsAuthorizedAdmin(RequestingId, Authorization))
             *  {
             *      result = false;
             *  }
             * }
             * else if (!this.IsAuthorizedRider(RequestingId, Authorization))
             * {
             *  result = false;
             * }
             *
             * return result;
             */
        }