reset.html 13 KB

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