1
+ <script lang =" ts" >
2
+ import { browser } from " $app/environment" ;
3
+ import { goto } from " $app/navigation" ;
4
+ import { refreshUser , token } from " $lib/user" ;
5
+ import Navbar from " $lib/components/navbar.svelte" ;
6
+ import { OTPRoot , OTPInput } from " @jimmyverburgt/svelte-input-otp" ;
7
+ import { api } from " $lib/api" ;
8
+
9
+ $ : if (browser && ! $token ) goto (" /login" );
10
+
11
+ let errorEl: HTMLSpanElement ;
12
+ let value = " " ;
13
+
14
+ function onComplete(code : string ) {
15
+ errorEl .textContent = " " ;
16
+
17
+ api (" account/mcAccount?code=" + code , true , " POST" )
18
+ .then (() => {
19
+ refreshUser ();
20
+ goto (" /account" );
21
+ })
22
+ .catch (error => {
23
+ value = " " ;
24
+ errorEl .textContent = error ;
25
+ });
26
+ }
27
+ </script >
28
+
29
+ <Navbar />
30
+
31
+ <div class =" container" >
32
+ <div >
33
+ <h1 >Add MC account</h1 >
34
+
35
+ <ol >
36
+ <li >Launch your Minecraft client and join our server with the IP <span class =" ip" >mcauth.meteorclient.com</span ></li >
37
+ <li >You will be immediatelly kicked with a one-time 6-digit code</li >
38
+ <li >Write the code into the input box below</li >
39
+ </ol >
40
+
41
+ <OTPRoot maxLength ={6 } autoFocus ={true } inputMode ="numeric" onComplete ={onComplete } bind:value className =" otp-root" >
42
+ <OTPInput index ={0 } className =" otp-input" focusClassName =" focused" />
43
+ <OTPInput index ={1 } className =" otp-input" focusClassName =" focused" />
44
+ <OTPInput index ={2 } className =" otp-input" focusClassName =" focused" />
45
+ <OTPInput index ={3 } className =" otp-input" focusClassName =" focused" />
46
+ <OTPInput index ={4 } className =" otp-input" focusClassName =" focused" />
47
+ <OTPInput index ={5 } className =" otp-input" focusClassName =" focused" />
48
+ </OTPRoot >
49
+
50
+ <span class ="error" bind:this ={errorEl }></span >
51
+ </div >
52
+ </div >
53
+
54
+ <style >
55
+ .container > div {
56
+ display : flex ;
57
+ flex-direction : column ;
58
+ }
59
+
60
+ h1 {
61
+ color : black ;
62
+ }
63
+
64
+ ol {
65
+ margin : 2rem 0 ;
66
+ }
67
+
68
+ li {
69
+ text-align : left ;
70
+ }
71
+
72
+ li ::marker {
73
+ font-weight : bold ;
74
+ }
75
+
76
+ .ip {
77
+ background-color : rgb (190 , 190 , 190 );
78
+ padding : 0.2rem 0.4rem ;
79
+ border-radius : 0.375rem ;
80
+ box-shadow : inset 0 -3px 0 rgb (99 110 123 / 40% );
81
+ }
82
+
83
+ :global(.otp-root ) {
84
+ display : flex ;
85
+ justify-content : center ;
86
+ gap : 0.25rem ;
87
+
88
+ color : black ;
89
+ font-size : 2rem ;
90
+ }
91
+
92
+ :global(.otp-input ) {
93
+ width : 1em ;
94
+ height : 1.4em ;
95
+
96
+ border : 1px rgb (80 , 80 , 80 ) solid ;
97
+ border-radius : 0.325rem ;
98
+ }
99
+
100
+ :global(.otp-input.focused ) {
101
+ border-width : 2px ;
102
+ border-color : black ;
103
+ }
104
+
105
+ .error {
106
+ color : red ;
107
+ }
108
+ </style >
0 commit comments