tasks.json controller: add DELETE call

resets the per-user file to upstream
This commit is contained in:
Standa Lukeš 2020-10-23 12:14:24 +00:00
parent 50b8264971
commit 6bbf59c32d

View file

@ -68,5 +68,24 @@ namespace Ksp.WebServer.Controllers
await System.IO.File.WriteAllTextAsync(TasksJsonFile(suffix), await rdr.ReadToEndAsync());
return Ok();
}
[HttpDelete]
public async Task<IActionResult> Delete()
{
if (env.IsDevelopment())
{
return BadRequest();
}
else
{
if (KspAuthCookie is null)
return StatusCode(401);
var user = await auth.VerifyUser(KspAuthCookie);
if (user == null)
return StatusCode(403);
System.IO.File.Delete(TasksJsonFile("-" + user.Id.Value));
return Ok();
}
}
}
}