Login button

This commit is contained in:
Settel 2021-08-03 14:47:48 +02:00
parent 4d1d4491b7
commit bd8d01d7df

View File

@ -8,13 +8,11 @@
Play! Play!
</NuxtLink> </NuxtLink>
</template> </template>
<div v-else> <form v-else v-on:submit="login">
<input <input
v-model="authCode" v-model="authCode"
class="startpage__authinput" class="startpage__authinput"
type="text" type="text"
id="authcode"
name="authcode"
value="" value=""
size="6" size="6"
maxlength="6" maxlength="6"
@ -25,7 +23,10 @@
value="Go" value="Go"
:class="[ 'startpage__authbutton', { disabled: loginDisabled }]" :class="[ 'startpage__authbutton', { disabled: loginDisabled }]"
/> />
<div class="startpage__errormessage" v-if="errorMessage">
{{ errorMessage }}
</div> </div>
</form>
</template> </template>
</div> </div>
<div class="startpage__copyright"> <div class="startpage__copyright">
@ -40,6 +41,7 @@ export default {
return { return {
user: {}, user: {},
authCode: '', authCode: '',
errorMessage: '',
} }
}, },
async fetch() { async fetch() {
@ -55,8 +57,15 @@ export default {
}, },
}, },
methods: { methods: {
login() { async login(e) {
console.log('log in') e.preventDefault()
try {
await this.$axios.$get(`/api/login?code=${this.authCode}`)
this.$fetch()
} catch(e) {
this.authCode = ''
this.errorMessage = 'login failed'
}
}, },
}, },
} }
@ -124,6 +133,13 @@ export default {
} }
} }
&__errormessage {
padding: 8px;
font-family: Dosis;
font-weight: 800;
color: #ff8080;
}
&__copyright { &__copyright {
position: absolute; position: absolute;
right: 1em; right: 1em;