|
1 | 1 | <script> |
2 | 2 | import { onMount } from "svelte"; |
3 | | - |
| 3 | +
|
4 | 4 | // Components |
5 | 5 | import NavigationBar from "$lib/NavigationBar/NavigationBar.svelte"; |
6 | 6 | import NavigationMargin from "$lib/NavigationBar/NavMargin.svelte"; |
|
44 | 44 | let passwordValid = false; |
45 | 45 |
|
46 | 46 | const passwordRequirements = [ |
47 | | - {name: "password.requirement.length", value: false}, |
48 | | - {name: "password.requirement.casing", value: false}, |
49 | | - {name: "password.requirement.number", value: false}, |
50 | | - {name: "password.requirement.symbol", value: false}, |
51 | | - ] |
| 47 | + { name: "password.requirement.length", value: false }, |
| 48 | + { name: "password.requirement.casing", value: false }, |
| 49 | + { name: "password.requirement.number", value: false }, |
| 50 | + { name: "password.requirement.symbol", value: false }, |
| 51 | + ]; |
52 | 52 |
|
53 | 53 | async function checkIfValid() { |
54 | | - const passwordDoesNotMeetLength = password.length < 8 || password.length > 50; |
55 | | - const passwordMeetsTextInclude = password.match(/[a-z]/) && password.match(/[A-Z]/); |
| 54 | + const passwordDoesNotMeetLength = |
| 55 | + password.length < 8 || password.length > 50; |
| 56 | + const passwordMeetsTextInclude = |
| 57 | + password.match(/[a-z]/) && password.match(/[A-Z]/); |
56 | 58 | const passwordHasNumber = !!password.match(/[0-9]/); |
57 | 59 | const passwordMeetsSpecialInclude = !!password.match(/[^a-z0-9]/i); |
58 | 60 |
|
59 | | - const passwordCheck = passwordDoesNotMeetLength || !(passwordMeetsTextInclude && passwordMeetsSpecialInclude && passwordHasNumber); |
| 61 | + const passwordCheck = |
| 62 | + passwordDoesNotMeetLength || |
| 63 | + !( |
| 64 | + passwordMeetsTextInclude && |
| 65 | + passwordMeetsSpecialInclude && |
| 66 | + passwordHasNumber |
| 67 | + ); |
60 | 68 |
|
61 | 69 | passwordRequirements[0].value = !passwordDoesNotMeetLength; |
62 | 70 | passwordRequirements[1].value = passwordMeetsTextInclude; |
|
81 | 89 | function resetPassword() { |
82 | 90 | resetingPassword = true; |
83 | 91 | Authentication.resetPassword(email, state, password) |
84 | | - .then(() => { |
| 92 | + .then((token) => { |
| 93 | + localStorage.setItem("token", token); |
85 | 94 | resetingPassword = false; |
86 | | - alert(TranslationHandler.textSafe( |
87 | | - "password.update.success", |
88 | | - currentLang, |
89 | | - "Password changed successfully!" |
90 | | - )); |
| 95 | + alert( |
| 96 | + TranslationHandler.textSafe( |
| 97 | + "password.update.success", |
| 98 | + currentLang, |
| 99 | + "Password changed successfully!", |
| 100 | + ), |
| 101 | + ); |
91 | 102 | location.href = "/"; |
92 | 103 | }) |
93 | 104 | .catch((error) => { |
|
96 | 107 | }); |
97 | 108 | } |
98 | 109 | </script> |
99 | | - |
| 110 | + |
100 | 111 | <svelte:head> |
101 | 112 | <title>PenguinMod - Reset Password</title> |
102 | 113 | <meta name="title" content="PenguinMod - Reset Password" /> |
103 | 114 | <meta property="og:title" content="PenguinMod - Reset Password" /> |
104 | 115 | <meta property="twitter:title" content="PenguinMod - Reset Password" /> |
105 | | - <meta name="description" content="Reset your password for PenguinMod to regain access to your account with a new password" /> |
106 | | - <meta property="twitter:description" content="Reset your password for PenguinMod to regain access to your account with a new password" /> |
107 | | - <meta property="og:url" content="https://penguinmod.com/resetpassword"> |
108 | | - <meta property="twitter:url" content="https://penguinmod.com/resetpassword"> |
| 116 | + <meta |
| 117 | + name="description" |
| 118 | + content="Reset your password for PenguinMod to regain access to your account with a new password" |
| 119 | + /> |
| 120 | + <meta |
| 121 | + property="twitter:description" |
| 122 | + content="Reset your password for PenguinMod to regain access to your account with a new password" |
| 123 | + /> |
| 124 | + <meta property="og:url" content="https://penguinmod.com/resetpassword" /> |
| 125 | + <meta |
| 126 | + property="twitter:url" |
| 127 | + content="https://penguinmod.com/resetpassword" |
| 128 | + /> |
109 | 129 | </svelte:head> |
110 | | - |
| 130 | + |
111 | 131 | <NavigationBar /> |
112 | 132 |
|
113 | 133 | <div class="main"> |
114 | 134 | <NavigationMargin /> |
115 | 135 |
|
116 | 136 | <main> |
117 | 137 | <div class="profile-section"> |
118 | | - <img |
119 | | - src="/account/profile_sheet.png" |
120 | | - alt="Profiles" |
121 | | - /> |
| 138 | + <img src="/account/profile_sheet.png" alt="Profiles" /> |
122 | 139 | </div> |
123 | 140 | <h1 style="margin-block:4px">PenguinMod</h1> |
124 | 141 | <p> |
|
128 | 145 | lang={currentLang} |
129 | 146 | /> |
130 | 147 | </p> |
131 | | - |
| 148 | + |
132 | 149 | <span class="input-title"> |
133 | 150 | <LocalizedText |
134 | 151 | text="Password" |
|
142 | 159 | placeholder={TranslationHandler.textSafe( |
143 | 160 | "account.fields.password.placeholder", |
144 | 161 | currentLang, |
145 | | - "Remember to write it down!" |
| 162 | + "Remember to write it down!", |
146 | 163 | )} |
147 | 164 | data-valid={passwordValid} |
148 | 165 | maxlength="50" |
149 | 166 | on:input={passwordInputChanged} |
150 | | - on:focusin={() => focused = true} |
151 | | - on:focusout={() => focused = false} |
| 167 | + on:focusin={() => (focused = true)} |
| 168 | + on:focusout={() => (focused = false)} |
152 | 169 | /> |
153 | 170 | <button |
154 | 171 | class="password-show invert-on-dark" |
|
160 | 177 | <ChecksBox items={passwordRequirements} /> |
161 | 178 | {/if} |
162 | 179 |
|
163 | | - <button class="create-acc" data-canReset={canResetPassword} on:click={resetPassword}> |
| 180 | + <button |
| 181 | + class="create-acc" |
| 182 | + data-canReset={canResetPassword} |
| 183 | + on:click={resetPassword} |
| 184 | + > |
164 | 185 | {#if resetingPassword} |
165 | 186 | <LoadingSpinner icon="/loading_white.png" /> |
166 | 187 | {:else} |
|
173 | 194 | </button> |
174 | 195 | </main> |
175 | 196 | </div> |
176 | | - |
| 197 | + |
177 | 198 | <style> |
178 | 199 | * { |
179 | 200 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; |
|
241 | 262 | background: #111; |
242 | 263 | color: white; |
243 | 264 | } |
244 | | - |
| 265 | +
|
245 | 266 | main input[data-valid="true"] { |
246 | 267 | border-color: rgb(0, 187, 0) !important; |
247 | 268 | } |
|
257 | 278 | height: calc(100% - 8px); |
258 | 279 | border: 0; |
259 | 280 | background: transparent; |
260 | | - background-image: url('account/showpassword.svg'); |
| 281 | + background-image: url("account/showpassword.svg"); |
261 | 282 | background-size: 100% 100%; |
262 | 283 | opacity: 0.7; |
263 | 284 | cursor: pointer; |
264 | 285 | } |
265 | 286 | .password-show[data-visible="true"] { |
266 | | - background-image: url('account/hidepassword.svg'); |
| 287 | + background-image: url("account/hidepassword.svg"); |
267 | 288 | background-size: 100% 100%; |
268 | 289 | } |
269 | 290 | :global(body.dark-mode) .invert-on-dark { |
|
288 | 309 | padding: 4px 8px; |
289 | 310 | width: 60%; |
290 | 311 | margin-top: 4px; |
291 | | - |
| 312 | +
|
292 | 313 | display: flex; |
293 | 314 | flex-direction: row; |
294 | 315 | align-items: center; |
295 | 316 | justify-content: center; |
296 | 317 | border: 1px solid rgba(0, 0, 0, 0.2); |
297 | 318 | font-size: 18px; |
298 | 319 | } |
299 | | - |
300 | | - .create-acc[data-canReset=true] { |
| 320 | +
|
| 321 | + .create-acc[data-canReset="true"] { |
301 | 322 | background: #00c3ff; |
302 | 323 | cursor: pointer; |
303 | 324 | color: white; |
304 | 325 | } |
305 | 326 |
|
306 | | - :global(body.dark-mode) .create-acc[data-canReset=false] { |
| 327 | + :global(body.dark-mode) .create-acc[data-canReset="false"] { |
307 | 328 | background: #9c9c9c; |
308 | 329 | color: rgb(255, 255, 255); |
309 | 330 | } |
310 | 331 |
|
311 | | - .create-acc[data-canReset=false] { |
| 332 | + .create-acc[data-canReset="false"] { |
312 | 333 | background: #9c9c9c; |
313 | 334 | color: rgb(255, 255, 255); |
314 | 335 | cursor: not-allowed; |
|
331 | 352 | } |
332 | 353 |
|
333 | 354 | @keyframes profile-scroll { |
334 | | - 0%, 10% { |
| 355 | + 0%, |
| 356 | + 10% { |
335 | 357 | transform: translateX(0); |
336 | 358 | } |
337 | | - 15%, 25% { |
| 359 | + 15%, |
| 360 | + 25% { |
338 | 361 | transform: translateX(-96px); |
339 | 362 | } |
340 | | - 30%, 40% { |
| 363 | + 30%, |
| 364 | + 40% { |
341 | 365 | transform: translateX(-192px); |
342 | 366 | } |
343 | | - 45%, 55% { |
| 367 | + 45%, |
| 368 | + 55% { |
344 | 369 | transform: translateX(-288px); |
345 | 370 | } |
346 | | - 60%, 70% { |
| 371 | + 60%, |
| 372 | + 70% { |
347 | 373 | transform: translateX(-384px); |
348 | 374 | } |
349 | | - 75%, 85% { |
| 375 | + 75%, |
| 376 | + 85% { |
350 | 377 | transform: translateX(-480px); |
351 | 378 | } |
352 | | - 90%, 100% { |
| 379 | + 90%, |
| 380 | + 100% { |
353 | 381 | transform: translateX(-480px); |
354 | 382 | } |
355 | 383 | } |
|
0 commit comments