예제 #1
0
        public HttpResponseMessage AddAdmin([FromUri] string accessToken, string computer,
                                            [FromBody] AddAdministratorRequest adminRequest)
        {
            bool isAuth = CheckpointAuth.CheckCheckpointToken(accessToken);

            HttpResponseMessage response = new HttpResponseMessage();

            if (isAuth)
            {
                AddAdministratorResult result =
                    ServerHandler.AddAdministratorsByRequestObject(computer, adminRequest);

                response = Request.CreateResponse(HttpStatusCode.OK, result);
            }
            else
            {
                AddAdministratorResult result = new AddAdministratorResult(computer);
                result.message = "Invalid Token";

                response = Request.CreateResponse(HttpStatusCode.Forbidden, result);
            }

            return(response);
        }