Added login page.
This commit is contained in:
parent
c56f8f72c2
commit
6b1e20d544
|
@ -21,7 +21,7 @@
|
||||||
v-if="!authStore.loggedIn"
|
v-if="!authStore.loggedIn"
|
||||||
no-caps
|
no-caps
|
||||||
icon="person"
|
icon="person"
|
||||||
to="/login"
|
@click="goToLoginPage"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -29,8 +29,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAuthStore } from 'stores/auth-store';
|
import { useAuthStore } from 'stores/auth-store';
|
||||||
import api from 'src/api/main';
|
import api from 'src/api/main';
|
||||||
|
import {useRoute, useRouter} from 'vue-router';
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
async function goToLoginPage() {
|
||||||
|
await router.push({
|
||||||
|
path: '/login',
|
||||||
|
query: {
|
||||||
|
next: encodeURIComponent(route.path)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
@ -6,7 +6,6 @@ width for smaller screens.
|
||||||
Use this as the root component for any pages you create.
|
Use this as the root component for any pages you create.
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<q-page>
|
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<div class="col-xs-12 col-md-6 q-px-sm">
|
<div class="col-xs-12 col-md-6 q-px-sm">
|
||||||
<slot>
|
<slot>
|
||||||
|
@ -14,5 +13,4 @@ Use this as the root component for any pages you create.
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-page>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<q-page>
|
||||||
<StandardCenteredPage>
|
<StandardCenteredPage>
|
||||||
<q-input
|
<q-input
|
||||||
v-model="searchQuery"
|
v-model="searchQuery"
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
/>
|
/>
|
||||||
</q-list>
|
</q-list>
|
||||||
</StandardCenteredPage>
|
</StandardCenteredPage>
|
||||||
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
<template>
|
||||||
|
<StandardCenteredPage>
|
||||||
|
<h3 class="text-center">Login to Gymboard</h3>
|
||||||
|
<q-form @submit="tryLogin" @reset="resetLogin">
|
||||||
|
<SlimForm>
|
||||||
|
<div class="row">
|
||||||
|
<q-input
|
||||||
|
:label="$t('loginPage.email')"
|
||||||
|
v-model="loginModel.email"
|
||||||
|
class="col-12"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<q-input
|
||||||
|
:label="$t('loginPage.password')"
|
||||||
|
v-model="loginModel.password"
|
||||||
|
:type="passwordVisible ? 'text' : 'password'"
|
||||||
|
class="col-12"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon
|
||||||
|
:name="passwordVisible ? 'visibility' : 'visibility_off'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="passwordVisible = !passwordVisible"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<q-btn type="submit" label="Log in" color="primary" class="q-mt-md col-12" no-caps/>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<q-btn flat no-caps label="Create an account" color="secondary" class="q-mt-md col-12" style="text-decoration: underline"/>
|
||||||
|
</div>
|
||||||
|
</SlimForm>
|
||||||
|
</q-form>
|
||||||
|
</StandardCenteredPage>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import StandardCenteredPage from 'src/components/StandardCenteredPage.vue';
|
||||||
|
import SlimForm from 'components/SlimForm.vue';
|
||||||
|
import {ref} from 'vue';
|
||||||
|
import api from 'src/api/main';
|
||||||
|
import {useAuthStore} from 'stores/auth-store';
|
||||||
|
import {useRoute, useRouter} from 'vue-router';
|
||||||
|
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const loginModel = ref({
|
||||||
|
email: '',
|
||||||
|
password: ''
|
||||||
|
});
|
||||||
|
const passwordVisible = ref(false);
|
||||||
|
|
||||||
|
async function tryLogin() {
|
||||||
|
console.log('logging in...');
|
||||||
|
try {
|
||||||
|
await api.auth.login(authStore, loginModel.value);
|
||||||
|
const dest = route.query.next ? decodeURIComponent(route.query.next as string) : '/';
|
||||||
|
await router.push(dest);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetLogin() {
|
||||||
|
loginModel.value.email = '';
|
||||||
|
loginModel.value.password = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<q-page>
|
||||||
<StandardCenteredPage>
|
<StandardCenteredPage>
|
||||||
<h3>Testing Page</h3>
|
<h3>Testing Page</h3>
|
||||||
<p>
|
<p>
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
<q-btn label="Logout" @click="api.auth.logout(authStore)" />
|
<q-btn label="Logout" @click="api.auth.logout(authStore)" />
|
||||||
</div>
|
</div>
|
||||||
</StandardCenteredPage>
|
</StandardCenteredPage>
|
||||||
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<q-page>
|
||||||
<StandardCenteredPage v-if="gym">
|
<StandardCenteredPage v-if="gym">
|
||||||
<h3 class="q-my-md text-center">{{ gym.displayName }}</h3>
|
<h3 class="q-my-md text-center">{{ gym.displayName }}</h3>
|
||||||
<q-btn-group spread square push>
|
<q-btn-group spread square push>
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
</q-btn-group>
|
</q-btn-group>
|
||||||
<router-view />
|
<router-view />
|
||||||
</StandardCenteredPage>
|
</StandardCenteredPage>
|
||||||
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -6,6 +6,7 @@ import GymSubmissionPage from 'pages/gym/GymSubmissionPage.vue';
|
||||||
import GymHomePage from 'pages/gym/GymHomePage.vue';
|
import GymHomePage from 'pages/gym/GymHomePage.vue';
|
||||||
import GymLeaderboardsPage from 'pages/gym/GymLeaderboardsPage.vue';
|
import GymLeaderboardsPage from 'pages/gym/GymLeaderboardsPage.vue';
|
||||||
import TestingPage from 'pages/TestingPage.vue';
|
import TestingPage from 'pages/TestingPage.vue';
|
||||||
|
import LoginPage from 'pages/LoginPage.vue';
|
||||||
|
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
|
@ -25,6 +26,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{ path: '/login', component: LoginPage },
|
||||||
|
|
||||||
// Always leave this as last one,
|
// Always leave this as last one,
|
||||||
// but you can also remove it
|
// but you can also remove it
|
||||||
|
|
Loading…
Reference in New Issue