You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web.Http;
  4. using Authentication_test.DBO;
  5. using iiie.Authentication.Business;
  6. using iiie.Authentication.Business.JWT;
  7. namespace Authentication_test.Controllers
  8. {
  9. public class ValuesController : ApiController
  10. {
  11. [AuthFilter]
  12. public IEnumerable<string> Post()
  13. {
  14. return new[] { "value1", "value2" };
  15. }
  16. [AuthFilter((int)UserRoles.Root)]
  17. public IEnumerable<string> Get()
  18. {
  19. return new [] { "value1", "value2" };
  20. }
  21. [AuthFilter((int)UserRoles.NotRoot)]
  22. public string Get(int id)
  23. {
  24. return UserStorage.BasicUserDbo.Username + " " + UserStorage.BasicUserDbo.TokenData;
  25. }
  26. [Route("api/login")]
  27. [HttpGet]
  28. public string Login(string username)
  29. {
  30. return TokenManager.GetToken(username, "", new
  31. {
  32. Date = DateTime.Now
  33. });
  34. }
  35. }
  36. }