Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. namespace ArtFind.Web.Controllers
  2. {
  3.  
  4. [RoutePrefix("Users")]
  5. public class UsersController : BaseController
  6. {
  7.  
  8. private IUsersService _usersService;
  9. private IFlashMessageService _flashmessageService;
  10. private IConfigurationService _configurationService;
  11. private ICryptographyService _cryptographyService;
  12.  
  13.  
  14. public UsersController(IUsersService usersService, IFlashMessageService flashmessageService, IConfigurationService configurationService, ICryptographyService cryptographyService)
  15. {
  16. _usersService = usersService;
  17. _flashmessageService = flashmessageService;
  18. _configurationService = configurationService;
  19. _cryptographyService = cryptographyService;
  20.  
  21. }
  22.  
  23. [NonAction]
  24. [Route("")]//This route is superceded by the Adminindex.
  25. public ActionResult Index()
  26. {
  27. return View();
  28. }
  29.  
  30. [Route("~/admin/users")]
  31. public ActionResult AdminIndex()
  32. {
  33. return View();
  34. }
  35.  
  36. [Route("~/admin/users/{id:int}/edit")]
  37. public ActionResult AdminEdit(int id)
  38. {
  39. ItemViewModel<int> viewById = new ItemViewModel<int>();
  40. viewById.Item = id;
  41. return View("Create", viewById);
  42. }
  43.  
  44. [Route("logout")]
  45. public ActionResult Logout()
  46. {
  47. return View();
  48. }
  49.  
  50. [Route("{id:int}/confirm-email"), AllowAnonymous]
  51. public ActionResult ConfirmEmail(int id, string code)
  52. {
  53. string hmac = _cryptographyService.HashMessage("confirmEmail:" + id);
  54. if (code == hmac)
  55. {
  56. _usersService.ConfirmEmail(id);
  57. _flashmessageService.Set("Your email is confirmed. You may now log in to Art Find");
  58. return Redirect("~/");
  59. }
  60. else {
  61. _flashmessageService.Set("An error occurred");
  62. return Redirect("~/");
  63. }
  64. }
  65.  
  66. [Route("{id}/reset-password"), AllowAnonymous]
  67. public ActionResult ResetPassword(int id, DateTime expiry, string code)
  68. {
  69. ResetPasswordViewModel model = new ResetPasswordViewModel();
  70. model.Expiry = expiry;
  71. model.Code = code;
  72. model.Id = id;
  73. return View(model);
  74. }
  75.  
  76. [Route("~/settings")]
  77. public ActionResult Settings()
  78. {
  79. UsersSettingsViewModel model = new UsersSettingsViewModel();
  80. model.FacebookAppId = _configurationService.FacebookAppId;
  81. return View(model);
  82. }
  83.  
  84. [Route("rankings")]
  85. public ActionResult Rankings()
  86. {
  87. return View();
  88. }
  89.  
  90. [Route("~/admin/users/{userId:int}/games")]
  91. public ActionResult GamesIndex(int userId)
  92. {
  93. ItemViewModel<int> viewById = new ItemViewModel<int>();
  94. viewById.Item = userId;
  95. return View(viewById);
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement