เพิ่มคิวรี่ ตรวจสอบสิทธิ ของหน้า ทำข้อตกลง

This commit is contained in:
Nakorn Rientrakrunchai
2021-02-12 16:11:14 +07:00
parent 7b525b9784
commit 1aba912679
5 changed files with 71 additions and 9 deletions

View File

@@ -69,10 +69,20 @@ namespace TodoAPI2.Controllers
{
try
{
if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized();
var result = _repository.GetWithSelection(id);
if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized();
return Ok(result);
if (!string.IsNullOrEmpty(HttpContext.Request.Cookies["user_id"]))
{
var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]);
var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid));
var result = _repository.GetWithSelection(id, e.id);
return Ok(result);
}
else
{
return Unauthorized();
}
}
catch (Exception ex)
{