The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
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.

UserAreaRegistration.cs 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System.Collections.Generic;
  2. using System.Web.Mvc;
  3. using System.Web.Optimization;
  4. using Teknik.Configuration;
  5. using Teknik.Utilities;
  6. namespace Teknik.Areas.Users
  7. {
  8. public class UserAreaRegistration : AreaRegistration
  9. {
  10. public override string AreaName
  11. {
  12. get
  13. {
  14. return "User";
  15. }
  16. }
  17. public override void RegisterArea(AreaRegistrationContext context)
  18. {
  19. Config config = Config.Load();
  20. context.MapSubdomainRoute(
  21. "User.GetPremium", // Route name
  22. new List<string>() { "user" }, // Subdomains
  23. new List<string>() { config.Host }, // domains
  24. "GetPremium", // URL with parameters
  25. new { controller = "User", action = "GetPremium" }, // Parameter defaults
  26. new[] { typeof(Controllers.UserController).Namespace }
  27. );
  28. context.MapSubdomainRoute(
  29. "User.Login", // Route name
  30. new List<string>() { "user" }, // Subdomains
  31. new List<string>() { config.Host }, // domains
  32. "Login", // URL with parameters
  33. new { controller = "User", action = "Login" }, // Parameter defaults
  34. new[] { typeof(Controllers.UserController).Namespace }
  35. );
  36. context.MapSubdomainRoute(
  37. "User.Logout", // Route name
  38. new List<string>() { "user" }, // Subdomains
  39. new List<string>() { config.Host }, // domains
  40. "Logout", // URL with parameters
  41. new { controller = "User", action = "Logout" }, // Parameter defaults
  42. new[] { typeof(Controllers.UserController).Namespace }
  43. );
  44. context.MapSubdomainRoute(
  45. "User.Register", // Route name
  46. new List<string>() { "user" }, // Subdomains
  47. new List<string>() { config.Host }, // domains
  48. "Register", // URL with parameters
  49. new { controller = "User", action = "Register" }, // Parameter defaults
  50. new[] { typeof(Controllers.UserController).Namespace }
  51. );
  52. context.MapSubdomainRoute(
  53. "User.Settings", // Route name
  54. new List<string>() { "user" }, // Subdomains
  55. new List<string>() { config.Host }, // domains
  56. "Settings", // URL with parameters
  57. new { controller = "User", action = "Settings" }, // Parameter defaults
  58. new[] { typeof(Controllers.UserController).Namespace }
  59. );
  60. context.MapSubdomainRoute(
  61. "User.ResetPassword", // Route name
  62. new List<string>() { "user" }, // Subdomains
  63. new List<string>() { config.Host }, // domains
  64. "Reset/{username}", // URL with parameters
  65. new { controller = "User", action = "ResetPassword", username = UrlParameter.Optional }, // Parameter defaults
  66. new[] { typeof(Controllers.UserController).Namespace }
  67. );
  68. context.MapSubdomainRoute(
  69. "User.VerifyResetPassword", // Route name
  70. new List<string>() { "user" }, // Subdomains
  71. new List<string>() { config.Host }, // domains
  72. "Reset/{username}/{code}", // URL with parameters
  73. new { controller = "User", action = "VerifyResetPassword" }, // Parameter defaults
  74. new[] { typeof(Controllers.UserController).Namespace }
  75. );
  76. context.MapSubdomainRoute(
  77. "User.VerifyRecoveryEmail", // Route name
  78. new List<string>() { "user" }, // Subdomains
  79. new List<string>() { config.Host }, // domains
  80. "VerifyEmail/{code}", // URL with parameters
  81. new { controller = "User", action = "VerifyRecoveryEmail" }, // Parameter defaults
  82. new[] { typeof(Controllers.UserController).Namespace }
  83. );
  84. context.MapSubdomainRoute(
  85. "User.CheckAuthenticatorCode", // Route name
  86. new List<string>() { "user" }, // Subdomains
  87. new List<string>() { config.Host }, // domains
  88. "CheckAuthCode", // URL with parameters
  89. new { controller = "User", action = "ConfirmTwoFactorAuth" }, // Parameter defaults
  90. new[] { typeof(Controllers.UserController).Namespace }
  91. );
  92. context.MapSubdomainRoute(
  93. "User.ViewProfile", // Route name
  94. new List<string>() { "user" }, // Subdomains
  95. new List<string>() { config.Host }, // domains
  96. "u/{username}", // URL with parameters
  97. new { controller = "User", action = "ViewProfile", username = UrlParameter.Optional }, // Parameter defaults
  98. new[] { typeof(Controllers.UserController).Namespace }
  99. );
  100. context.MapSubdomainRoute(
  101. "User.PGPKey", // Route name
  102. new List<string>() { "user" }, // Subdomains
  103. new List<string>() { config.Host }, // domains
  104. "u/{username}/PGP", // URL with parameters
  105. new { controller = "User", action = "ViewRawPGP" }, // Parameter defaults
  106. new[] { typeof(Controllers.UserController).Namespace }
  107. );
  108. context.MapSubdomainRoute(
  109. "User.Action", // Route name
  110. new List<string>() { "user" }, // Subdomains
  111. new List<string>() { config.Host }, // domains
  112. "Action/{action}", // URL with parameters
  113. new { controller = "User", action = "Index" }, // Parameter defaults
  114. new[] { typeof(Controllers.UserController).Namespace }
  115. );
  116. // Register Script Bundle
  117. BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/user", config.CdnHost).Include(
  118. "~/Scripts/bootbox/bootbox.min.js",
  119. "~/Scripts/jquery.blockUI.js",
  120. "~/Scripts/bootstrap-switch.js",
  121. "~/Areas/User/Scripts/User.js"));
  122. // Register Script Bundle
  123. BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/checkAuthCode", config.CdnHost).Include(
  124. "~/Areas/User/Scripts/CheckAuthCode.js"));
  125. // Register Script Bundle
  126. BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/profile", config.CdnHost).Include(
  127. "~/Scripts/bootbox/bootbox.min.js",
  128. "~/Areas/User/Scripts/Profile.js"));
  129. // Register Style Bundles
  130. BundleTable.Bundles.Add(new CdnStyleBundle("~/Content/user", config.CdnHost).Include(
  131. "~/Content/bootstrap-switch/bootstrap3/bootstrap-switch.css"));
  132. }
  133. }
  134. }