12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.Web.Http;
- using Authentication_test.DBO;
- using iiie.Authentication.Business;
- using iiie.Authentication.Business.JWT;
-
- namespace Authentication_test.Controllers
- {
- public class ValuesController : ApiController
- {
- [AuthFilter]
- public IEnumerable<string> Post()
- {
- return new[] { "value1", "value2" };
- }
-
- [AuthFilter((int)UserRoles.Root)]
- public IEnumerable<string> Get()
- {
- return new [] { "value1", "value2" };
- }
-
- [AuthFilter((int)UserRoles.NotRoot)]
- public string Get(int id)
- {
- return UserStorage.BasicUserDbo.Username + " " + UserStorage.BasicUserDbo.TokenData;
- }
-
- [Route("api/login")]
- [HttpGet]
- public string Login(string username)
- {
- return TokenManager.GetToken(username, "", new
- {
- Date = DateTime.Now
- });
- }
- }
- }
|