-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use 6-digit code to add MC accounts instead of usernames
- Loading branch information
1 parent
d0bd9d2
commit f4b5f7d
Showing
3 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script lang="ts"> | ||
import { browser } from "$app/environment"; | ||
import { goto } from "$app/navigation"; | ||
import { refreshUser, token } from "$lib/user"; | ||
import Navbar from "$lib/components/navbar.svelte"; | ||
import { OTPRoot, OTPInput } from "@jimmyverburgt/svelte-input-otp"; | ||
import { api } from "$lib/api"; | ||
$: if (browser && !$token) goto("/login"); | ||
let errorEl: HTMLSpanElement; | ||
let value = ""; | ||
function onComplete(code: string) { | ||
errorEl.textContent = ""; | ||
api("account/mcAccount?code=" + code, true, "POST") | ||
.then(() => { | ||
refreshUser(); | ||
goto("/account"); | ||
}) | ||
.catch(error => { | ||
value = ""; | ||
errorEl.textContent = error; | ||
}); | ||
} | ||
</script> | ||
|
||
<Navbar /> | ||
|
||
<div class="container"> | ||
<div> | ||
<h1>Add MC account</h1> | ||
|
||
<ol> | ||
<li>Launch your Minecraft client and join our server with the IP <span class="ip">mcauth.meteorclient.com</span></li> | ||
<li>You will be immediatelly kicked with a one-time 6-digit code</li> | ||
<li>Write the code into the input box below</li> | ||
</ol> | ||
|
||
<OTPRoot maxLength={6} autoFocus={true} inputMode="numeric" onComplete={onComplete} bind:value className="otp-root"> | ||
<OTPInput index={0} className="otp-input" focusClassName="focused" /> | ||
<OTPInput index={1} className="otp-input" focusClassName="focused" /> | ||
<OTPInput index={2} className="otp-input" focusClassName="focused" /> | ||
<OTPInput index={3} className="otp-input" focusClassName="focused" /> | ||
<OTPInput index={4} className="otp-input" focusClassName="focused" /> | ||
<OTPInput index={5} className="otp-input" focusClassName="focused" /> | ||
</OTPRoot> | ||
|
||
<span class="error" bind:this={errorEl}></span> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.container > div { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
h1 { | ||
color: black; | ||
} | ||
ol { | ||
margin: 2rem 0; | ||
} | ||
li { | ||
text-align: left; | ||
} | ||
li::marker { | ||
font-weight: bold; | ||
} | ||
.ip { | ||
background-color: rgb(190, 190, 190); | ||
padding: 0.2rem 0.4rem; | ||
border-radius: 0.375rem; | ||
box-shadow: inset 0 -3px 0 rgb(99 110 123 / 40%); | ||
} | ||
:global(.otp-root) { | ||
display: flex; | ||
justify-content: center; | ||
gap: 0.25rem; | ||
color: black; | ||
font-size: 2rem; | ||
} | ||
:global(.otp-input) { | ||
width: 1em; | ||
height: 1.4em; | ||
border: 1px rgb(80, 80, 80) solid; | ||
border-radius: 0.325rem; | ||
} | ||
:global(.otp-input.focused) { | ||
border-width: 2px; | ||
border-color: black; | ||
} | ||
.error { | ||
color: red; | ||
} | ||
</style> |