From 3c140656ebe6ed34dda9356a01dbff205651e641 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 14 Feb 2019 23:05:04 +0800 Subject: Develop user token interface. --- Timeline/Controllers/UserTestController.cs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Timeline/Controllers/UserTestController.cs (limited to 'Timeline/Controllers/UserTestController.cs') diff --git a/Timeline/Controllers/UserTestController.cs b/Timeline/Controllers/UserTestController.cs new file mode 100644 index 00000000..7fb6850b --- /dev/null +++ b/Timeline/Controllers/UserTestController.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace Timeline.Controllers +{ + [Route("api/test/User")] + public class UserTestController : Controller + { + [HttpGet("[action]")] + [Authorize] + public ActionResult NeedAuthorize() + { + return Ok(); + } + + [HttpGet("[action]")] + [Authorize(Roles = "User,Admin")] + public ActionResult BothUserAndAdmin() + { + return Ok(); + } + + [HttpGet("[action]")] + [Authorize(Roles = "Admin")] + public ActionResult OnlyAdmin() + { + return Ok(); + } + } +} -- cgit v1.2.3