reset.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="robots" content="noindex" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="icon" type="image/png" href="./favicon.png" />
  8. <title>Account Reset | Zoraxy</title>
  9. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  10. <script type="application/javascript" src="script/jquery-3.6.0.min.js"></script>
  11. <script type="application/javascript" src="script/semantic/semantic.min.js"></script>
  12. <style>
  13. body {
  14. background: rgb(38,60,71);
  15. background: linear-gradient(215deg, rgba(38,60,71,1) 13%, rgba(2,3,42,1) 84%);
  16. }
  17. .background{
  18. position: fixed;
  19. top: 0;
  20. right: 0;
  21. height: 100%;
  22. width: 100%;
  23. opacity: 0.8;
  24. z-index: -99;
  25. background-image: url("img/public/bg2.jpg");
  26. background-size: auto 100%;
  27. background-position: right top;
  28. background-repeat: no-repeat;
  29. overflow-x: hidden;
  30. }
  31. form {
  32. margin:auto;
  33. }
  34. #errmsg{
  35. color: #9f3a38;
  36. margin-top: 1em;
  37. margin-bottom: 0.4em;
  38. text-align: left;
  39. }
  40. .backBtn{
  41. position: fixed;
  42. top: 1em;
  43. left: 1em;
  44. transition: opacity 0.3s linear;
  45. }
  46. .backBtn:hover{
  47. opacity: 0.8;
  48. }
  49. #loginForm {
  50. border-radius: 1em;
  51. width: 25em;
  52. height: 550px;
  53. position: absolute; /*Can also be `fixed`*/
  54. left: 0;
  55. right: 0;
  56. top: 0;
  57. bottom: 0;
  58. margin: auto;
  59. /*Solves a problem in which the content is being cut when the div is smaller than its' wrapper:*/
  60. max-width: 100%;
  61. max-height: 100%;
  62. overflow: auto;
  63. background-color: white;
  64. }
  65. .wavebase {
  66. position:fixed;
  67. bottom: 0;
  68. left: 0;
  69. width: 100%;
  70. height:5vh;
  71. text-align:center;
  72. padding-top: 1em;
  73. background-color: white;
  74. }
  75. /*
  76. Waves CSS
  77. */
  78. #wavesWrapper{
  79. position: fixed;
  80. bottom: 5vh;
  81. width: 100%;
  82. left: 0;
  83. }
  84. .waves {
  85. position:relative;
  86. width: 100%;
  87. height:15vh;
  88. margin-bottom:-7px; /*Fix for safari gap*/
  89. min-height:100px;
  90. max-height:150px;
  91. }
  92. .parallax > use {
  93. animation: move-forever 25s cubic-bezier(.55,.5,.45,.5) infinite;
  94. }
  95. .parallax > use:nth-child(1) {
  96. animation-delay: -8s;
  97. animation-duration: 28s;
  98. }
  99. .parallax > use:nth-child(2) {
  100. animation-delay: -12s;
  101. animation-duration: 40s;
  102. }
  103. .parallax > use:nth-child(3) {
  104. animation-delay: -16s;
  105. animation-duration: 52s;
  106. }
  107. .parallax > use:nth-child(4) {
  108. animation-delay: -20s;
  109. animation-duration: 80s;
  110. }
  111. @keyframes move-forever {
  112. 0% {
  113. transform: translate3d(-90px,0,0);
  114. }
  115. 100% {
  116. transform: translate3d(85px,0,0);
  117. }
  118. }
  119. /*Shrinking for mobile*/
  120. @media (max-width: 768px) {
  121. .waves {
  122. height:40px;
  123. min-height:40px;
  124. }
  125. }
  126. </style>
  127. </head>
  128. <body>
  129. <a class="backBtn" href="/">
  130. <i class="huge chevron circle left icon" style="color: whitesmoke;"></i>
  131. </a>
  132. <div id="loginForm" class="ui middle aligned center aligned grid">
  133. <div class="column">
  134. <form class="ui large form">
  135. <div class="ui basic segment">
  136. <img class="ui fluid image" src="img/public/logo.svg" style="pointer-events:none;">
  137. <p>Reset Password</p>
  138. <div class="field">
  139. <div class="ui left icon input">
  140. <i class="user icon"></i>
  141. <input id="username" type="text" name="username" placeholder="Username">
  142. </div>
  143. </div>
  144. <div class="field">
  145. <div class="ui left icon input">
  146. <i class="ticket alternate icon"></i>
  147. <input id="token" type="text" name="token" placeholder="Token">
  148. </div>
  149. </div>
  150. <div class="field">
  151. <div class="ui left icon input">
  152. <i class="lock icon"></i>
  153. <input id="magic" type="password" name="New password" placeholder="New Password">
  154. </div>
  155. </div>
  156. <div id="resetBtn" class="ui fluid basic green button">Set New Password</div>
  157. <div id="errmsg" class="ui red message" style="display: none;">
  158. <i class="red remove icon"></i> Unknown Error Occured
  159. </div>
  160. <div id="succmsg" class="ui message" style="display:none;">
  161. <i class="ui green check circle icon"></i> Password Updated. <br><small>Redirecting to <a href="/">login page</a> in 3 seconds</small>
  162. </div>
  163. <div id="countdown" class="ui message" style="color: grey;">
  164. <span id="countdownText"><i class="ui loading circle notch icon"></i> Resend email in <span id="countdown-num">30</span> seconds</span>
  165. <a href="#" id="resendEmailLink" onclick="sendResetAccountEmail();">Resend Email</a>
  166. </div>
  167. </div>
  168. </form>
  169. </div>
  170. </div>
  171. <div id="wavesWrapper">
  172. <!-- CSS waves-->
  173. <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  174. viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
  175. <defs>
  176. <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
  177. </defs>
  178. <g class="parallax">
  179. <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.7" />
  180. <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.5)" />
  181. <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.3)" />
  182. <use xlink:href="#gentle-wave" x="48" y="7" fill="#fff" />
  183. </g>
  184. </svg>
  185. </div>
  186. <div class="wavebase">
  187. <p>Proudly powered by <a href="https://zoraxy.arozos.com" target="_blank">Zoraxy</a></p>
  188. </div>
  189. <script>
  190. var redirectionAddress = "/";
  191. var loginAddress = "/api/auth/login";
  192. $(".checkbox").checkbox();
  193. $(document).ready(function(){
  194. var currentdate = new Date();
  195. var datetime = currentdate.getDate() + "/"
  196. + (currentdate.getMonth()+1) + "/"
  197. + currentdate.getFullYear() + " "
  198. + currentdate.getHours() + ":"
  199. + currentdate.getMinutes() + ":"
  200. + currentdate.getSeconds();
  201. $("#requestTime").text(datetime);
  202. //Check if the user already logged in
  203. $.get("/api/auth/checkLogin",function(data){
  204. try{
  205. if (data === true || data.trim() == "true"){
  206. //User already logged in. Redirect to target page.
  207. if (redirectionAddress == ""){
  208. //Redirect back to index
  209. window.location.href = "/";
  210. }else{
  211. console.log(data);
  212. //window.location.href = redirectionAddress;
  213. }
  214. }
  215. }catch(ex){
  216. //Assume not logged in
  217. console.log(data);
  218. }
  219. });
  220. });
  221. //Bind reset password events
  222. $('#resetBtn').on('click', function() {
  223. // Get input values
  224. var username = $('#username').val();
  225. var token = $('#token').val();
  226. var newPassword = $('#magic').val();
  227. if (token.trim() == ""){
  228. $("#errmsg").html(`<i class="red circle times icon"></i> Token cannot be empty!`);
  229. $("#errmsg").show();
  230. return;
  231. }
  232. // Send POST request with input values as data
  233. $.post('/api/account/new', { username: username, token: token, newpw: newPassword })
  234. .done(function(data) {
  235. // Handle successful response
  236. if (data.error != undefined){
  237. $("#errmsg").html(`<i class="red circle times icon"></i> ` + data.error);
  238. $("#errmsg").show();
  239. }else{
  240. $("#errmsg").hide();
  241. $("#countdown").hide();
  242. $("#succmsg").show();
  243. setTimeout(function(){
  244. window.location.href = "/";
  245. }, 3000);
  246. }
  247. })
  248. .fail(function(error) {
  249. // Handle error response
  250. console.error(error);
  251. });
  252. });
  253. function updateYear() {
  254. const year = new Date().getFullYear();
  255. const elements = document.getElementsByClassName("year");
  256. for (let i = 0; i < elements.length; i++) {
  257. elements[i].textContent = year;
  258. }
  259. }
  260. updateYear();
  261. function startCountdown() {
  262. var count = 30;
  263. var countdownNum = $('#countdown-num');
  264. countdownNum.text(count);
  265. $("#countdownText").show();
  266. $('#resendEmailLink').hide();
  267. var countdownTimer = setInterval(function() {
  268. count--;
  269. if (count === 0) {
  270. clearInterval(countdownTimer);
  271. $("#countdownText").hide();
  272. $('#resendEmailLink').show();
  273. } else {
  274. countdownNum.text(count);
  275. }
  276. }, 1000);
  277. }
  278. //Send account reset email to preset admin account
  279. function sendResetAccountEmail(){
  280. $("#resendEmailLink").html(`<i class="ui loading spinner icon"></i> Sending Email`);
  281. $("#resendEmailLink").css({
  282. "opacity": "0.8",
  283. "pointer-events": "none"
  284. });
  285. $.get("/api/account/reset", function(data){
  286. $("#resendEmailLink").html(`<a href="#" onclick="sendResetAccountEmail();">Resend Email</a>`);
  287. $("#resendEmailLink").css({
  288. "opacity": "1",
  289. "pointer-events": "auto"
  290. });
  291. if (data.error !== undefined){
  292. alert(data.error);
  293. }else{
  294. //Start countdown again
  295. startCountdown();
  296. }
  297. });
  298. }
  299. $(".thisyear").text(new Date().getFullYear());
  300. function updateRenderElements(){
  301. if (window.innerHeight < 520){
  302. $(".bottombar").hide();
  303. }else{
  304. $(".bottombar").show();
  305. }
  306. }
  307. updateRenderElements();
  308. $(window).on("resize", function(){
  309. updateRenderElements();
  310. });
  311. //Start the countdown on redirect
  312. startCountdown();
  313. </script>
  314. </body>
  315. </html>