tasks.json controller: add DELETE call
resets the per-user file to upstream
This commit is contained in:
parent
50b8264971
commit
6bbf59c32d
1 changed files with 19 additions and 0 deletions
|
@ -68,5 +68,24 @@ namespace Ksp.WebServer.Controllers
|
||||||
await System.IO.File.WriteAllTextAsync(TasksJsonFile(suffix), await rdr.ReadToEndAsync());
|
await System.IO.File.WriteAllTextAsync(TasksJsonFile(suffix), await rdr.ReadToEndAsync());
|
||||||
return Ok();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue