Beispiel #1
0
        public async Task <IActionResult> DeletePluginAsync(int pluginId)
        {
            if (await _srv.GetPluginByIdAsync(pluginId) == null)
            {
                return(BadRequest(new GenericResponse
                {
                    Success = false,
                    Message = "Plugin with that Id does not exist."
                }));
            }

            var userId = HttpContext.User.FindFirstValue(ClaimTypes.Sid);

            if (!await _srv.UserIdOwnsPluginIdAsync(userId, pluginId))
            {
                return(Unauthorized(new GenericResponse
                {
                    Success = false,
                    Message = "Unauthorized to delete plugin."
                }));
            }

            await _srv.DeletePluginAsync(pluginId);

            return(Ok(new GenericResponse
            {
                Success = true,
                Message = "Deleted plugin."
            }));
        }