The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
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.

Settings.cshtml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. @model Teknik.Areas.Users.ViewModels.SettingsViewModel
  2. @using Teknik.Utilities
  3. @using Teknik.Areas.Users.ViewModels
  4. <script>
  5. var homeUrl = '@Url.SubRouteUrl("www", "Home.Index")';
  6. var editUserURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "Edit" })';
  7. var deleteUserURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "Delete" })';
  8. var resendVerifyURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "ResendVerifyRecoveryEmail"})';
  9. var confirmAuthSetupURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "VerifyAuthenticatorCode" })';
  10. var clearTrustedDevicesURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "ClearTrustedDevices" })';
  11. var generateTokenURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "GenerateToken" })';
  12. var revokeAllTokensURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "RevokeAllTokens" })';
  13. var editTokenNameURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "EditTokenName" })';
  14. var deleteTokenURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "DeleteToken" })';
  15. </script>
  16. @Styles.Render("~/Content/user")
  17. @Scripts.Render("~/bundles/user")
  18. <div class="container">
  19. @if (!Model.Error)
  20. {
  21. <div class="modal fade" id="authenticatorSetup" tabindex="-1" role="dialog" aria-labelledby="authenticatorSetupLabel" aria-hidden="true">
  22. <div class="modal-dialog">
  23. <div class="modal-content">
  24. <div class="modal-header">
  25. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
  26. <h4 class="modal-title" id="authSetupTitleLabel">Set Up a Third Party App to Generate Codes</h4>
  27. </div>
  28. <div class="modal-body">
  29. <div class="row">
  30. <div class="col-sm-12 text-center">
  31. <div id="authSetupStatus"></div>
  32. </div>
  33. </div>
  34. <form class="form" action="##" method="post" id="confirmAuthSetup">
  35. <p>To get a third party app working, either scan the QR code below or type the secret key into the app.</p>
  36. <div class="row">
  37. <div class="col-sm-4">
  38. <p class="text-muted">QR Code:</p>
  39. </div>
  40. <div class="col-sm-8">
  41. <img id="authQRCode" src="@Url.SubRouteUrl("user", "User.Action", new { action = "GenerateAuthQrCode", key = Model.SecuritySettings.TwoFactorKey })" width="200" height="200" alt="qr code" />
  42. </div>
  43. </div>
  44. <div class="row">
  45. <div class="col-sm-4">
  46. <p class="text-muted">Secret Key:</p>
  47. </div>
  48. <div class="col-sm-8">
  49. <span class="text-success" id="authSetupSecretKey">@Model.SecuritySettings.TwoFactorKey</span>
  50. </div>
  51. </div>
  52. <hr />
  53. <p>To confirm the third party app is set up correctly, enter the security code that appears on your phone.</p>
  54. <div class="row">
  55. <div class="col-sm-4">
  56. <p class="text-muted">Security Code:</p>
  57. </div>
  58. <div class="col-sm-6">
  59. <input class="form-control" id="auth_setup_code" name="auth_setup_code" title="Authenticator Security Code" type="text" />
  60. </div>
  61. </div>
  62. <hr />
  63. <div class="form-group text-right">
  64. <button class="btn btn-primary" id="auth_setup_verify" type="button" name="auth_setup_verify">Verify</button>
  65. </div>
  66. </form>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="row">
  72. <div class="col-sm-12">
  73. <form class="form" action="##" method="post" id="updateForm">
  74. <input name="update_userid" id="update_userid" type="hidden" value="@Model.UserID" />
  75. <!-- Tab Navigation -->
  76. <ul class="nav nav-tabs" id="settingTabs">
  77. <li class="active"><a href="#profile" data-toggle="tab"> Profile </a></li>
  78. <li><a href="#security" data-toggle="tab"> Security </a></li>
  79. <li><a href="#blog" data-toggle="tab"> Blog </a></li>
  80. <li><a href="#uploads" data-toggle="tab"> Uploads </a></li>
  81. </ul>
  82. <div class="tab-content">
  83. <!-- Profile Settings -->
  84. <div class="tab-pane active" id="profile">
  85. <div class="row">
  86. <div class="form-group col-sm-4">
  87. <label for="update_website"><h4>Website</h4></label>
  88. <input class="form-control" id="update_website" name="update_website" placeholder="http://www.noneofyourbusiness.com/" title="enter your website" type="text" value="@Model.UserSettings.Website" />
  89. </div>
  90. <div class="form-group col-sm-8">
  91. <label for="update_quote"><h4>Quote</h4></label>
  92. <input class="form-control" id="update_quote" name="update_quote" placeholder="I have a dream!" title="enter a memorable quote" type="text" value="@Model.UserSettings.Quote" maxlength="140" />
  93. </div>
  94. </div>
  95. <div class="row">
  96. <div class="form-group col-sm-12">
  97. <label for="update_about"><h4>About Yourself</h4></label>
  98. <textarea class="form-control" name="update_about" id="update_about" placeholder="I'm awesome" title="enter any information you want to share with the world." data-provide="markdown" rows="10">@Model.UserSettings.About</textarea>
  99. </div>
  100. </div>
  101. </div>
  102. <!-- Security Settings -->
  103. <div class="tab-pane" id="security">
  104. <div class="row">
  105. <div class="col-sm-4">
  106. <div class="row">
  107. <div class="form-group col-sm-12">
  108. <label for="update_password_current"><h4>Current Password</h4></label>
  109. <input class="form-control" name="update_password_current" id="update_password_current" placeholder="current password" title="enter your current password." type="password" />
  110. </div>
  111. </div>
  112. <div class="row">
  113. <div class="form-group col-sm-12">
  114. <label for="update_password"><h4>New Password</h4></label>
  115. <input class="form-control" name="update_password" id="update_password" placeholder="new password" title="enter your password." type="password" />
  116. </div>
  117. </div>
  118. <div class="row">
  119. <div class="form-group col-sm-12">
  120. <label for="update_password_confirm"><h4>Verify New Password</h4></label>
  121. <input class="form-control" name="update_password_confirm" id="update_password_confirm" placeholder="new password confirmed" title="enter your password again." type="password" />
  122. </div>
  123. </div>
  124. </div>
  125. <div class="col-sm-8">
  126. <label for="update_pgp_public_key"><h4>Public Key</h4></label>
  127. <textarea class="form-control" id="update_pgp_public_key" name="update_pgp_public_key" placeholder="Public Key Here" title="enter your pgp public key" rows="15">@Model.SecuritySettings.PGPSignature</textarea>
  128. </div>
  129. </div>
  130. <div class="row">
  131. <div class="col-sm-4 text-left">
  132. <div class="row">
  133. <div class="form-group col-sm-12">
  134. <label for="update_recovery_email"><h4>Recovery Email</h4></label>
  135. <input class="form-control" name="update_recovery_email" id="update_recovery_email" placeholder="user@example.com" title="enter a recovery email." type="text" value="@Model.SecuritySettings.RecoveryEmail" />
  136. @if (!string.IsNullOrEmpty(Model.SecuritySettings.RecoveryEmail))
  137. {
  138. <p class="form-control-static">
  139. @if (Model.SecuritySettings.RecoveryVerified)
  140. {
  141. <span class="text-success"><i class="fa fa-check"></i> Verified</span>
  142. }
  143. else
  144. {
  145. <span class="text-danger"><i class="fa fa-ban"></i> Unverified</span> <small><a href="#" class="text-primary" id="ResendVerification"><i class="fa fa-repeat"></i> Resend</a></small>
  146. }
  147. </p>
  148. }
  149. </div>
  150. </div>
  151. <div class="row">
  152. <div class="form-group col-sm-12 text-left">
  153. <label for="update_security_two_factor"><h4>Enable Two Factor Authentication</h4></label>
  154. <div class="checkbox">
  155. <label>
  156. <input id="update_security_two_factor" name="update_security_two_factor" title="whether two factor authentication should occur for this account" type="checkbox" value="true" @(Model.SecuritySettings.TwoFactorEnabled ? "checked" : string.Empty) />
  157. </label>
  158. </div>
  159. <p class="form-control-static @(Model.SecuritySettings.TwoFactorEnabled ? string.Empty : "hide")" id="setupAuthenticatorLink">
  160. <small><a href="#" class="text-primary" id="SetupAuthenticator" data-toggle="modal" data-target="#authenticatorSetup"><i class="fa fa-lock"></i> Set Up Authenticator</a></small>
  161. </p>
  162. </div>
  163. </div>
  164. <div class="row">
  165. <div class="form-group col-sm-12 text-left">
  166. <label for="update_security_allow_trusted"><h4>Allow Trusted Devices</h4></label>
  167. <div class="checkbox">
  168. <label>
  169. <input id="update_security_allow_trusted" name="update_security_allow_trusted" title="whether a device could be cached to bypass two factor authentication" type="checkbox" value="true" @(Model.SecuritySettings.AllowTrustedDevices ? "checked" : string.Empty) />
  170. </label>
  171. </div>
  172. <p class="form-control-static @(Model.SecuritySettings.AllowTrustedDevices ? string.Empty : "hide")" id="ClearDevicesLink">
  173. <small><a href="#" class="text-primary" id="ClearDevices">Clear Trusted Devices (@Model.TrustedDeviceCount)</a></small>
  174. </p>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="col-sm-8">
  179. <br />
  180. <label for="authTokens"><h4>Authentication Tokens</h4></label><span class="pull-right"><button type="button" class="btn btn-default" id="generate_token">Generate Token</button> <button type="button" class="btn btn-danger" id="revoke_all_tokens">Revoke All</button></span>
  181. <div id="authTokens" style="overflow-y: auto; max-height: 400px;">
  182. <ul class="list-group" id="authTokenList">
  183. @if (Model.AuthTokens.Any())
  184. {
  185. foreach (AuthTokenViewModel token in Model.AuthTokens)
  186. {
  187. @Html.Partial("AuthToken", token)
  188. }
  189. }
  190. else
  191. {
  192. <li class="list-group-item text-center" id="noAuthTokens">No Authentication Tokens</li>
  193. }
  194. </ul>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. <!-- Blog Settings -->
  200. <div class="tab-pane" id="blog">
  201. <div class="row">
  202. <div class="form-group col-sm-6">
  203. <label for="update_blog_title"><h4>Title</h4></label>
  204. <input class="form-control" id="update_blog_title" name="update_blog_title" placeholder="click bait" title="enter your blog's title" type="text" value="@Model.BlogSettings.Title" />
  205. </div>
  206. <div class="form-group col-sm-6">
  207. <label for="update_blog_description"><h4>Description</h4></label>
  208. <input class="form-control" id="update_blog_description" name="update_blog_description" placeholder="This blog is not worth reading." title="enter your blog's description" type="text" value="@Model.BlogSettings.Description" />
  209. </div>
  210. </div>
  211. </div>
  212. <!-- Upload Settings -->
  213. <div class="tab-pane" id="uploads">
  214. <div class="row">
  215. <div class="col-sm-6">
  216. <div class="checkbox">
  217. <label>
  218. <label for="update_upload_saveKey"><h4>Save Key on Server</h4></label>
  219. <input id="update_upload_saveKey" name="update_upload_saveKey" title="whether the key should be saved on the server or not" type="checkbox" value="true" @(Model.UploadSettings.SaveKey ? "checked" : string.Empty) />
  220. </label>
  221. </div>
  222. </div>
  223. <div class="col-sm-6">
  224. <div class="checkbox">
  225. <label>
  226. <label for="update_upload_serverSideEncrypt"><h4>Encrypt on Server Side</h4></label>
  227. <input id="update_upload_serverSideEncrypt" name="update_upload_serverSideEncrypt" title="whether the file should be encrypted server side or client side" type="checkbox" value="true" @(Model.UploadSettings.ServerSideEncrypt ? "checked" : string.Empty) />
  228. </label>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. <!-- Save Settings -->
  235. <div class="row">
  236. <div class="form-group col-sm-10">
  237. <br />
  238. <button class="btn btn-lg btn-success" id="update_submit" type="submit"><i class="glyphicon glyphicon-ok-sign"></i> Save</button>
  239. <button class="btn btn-lg" type="reset"><i class="glyphicon glyphicon-repeat"></i> Reset</button>
  240. </div>
  241. <div class="form-group col-sm-2">
  242. <br />
  243. <button type="button" class="btn btn-danger" id="delete_account">Delete Account</button>
  244. </div>
  245. </div>
  246. </form>
  247. </div><!--/col-9-->
  248. </div><!--/row-->
  249. }
  250. else
  251. {
  252. <div class="row">
  253. <div class="col-sm-12 text-center">
  254. <h2>Sorry, but I couldn't find that user.</h2>
  255. </div>
  256. </div>
  257. }
  258. </div>