Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): register page #45

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions apps/web/src/modules/auth/routes.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import { RawLocation, Route, RouteConfig } from 'vue-router';
import { NavigationGuard, RawLocation, Route, RouteConfig } from 'vue-router';
import store from '~app/core/store';
import { authActions, authGetters } from './store';

export enum AuthRoute {
LOGIN = 'auth-login',
LOGOUT = 'auth-logout',
REGISTER = 'auth-register',
PROFILE = 'auth-profile',
}

const loggedInGuard: NavigationGuard = (to, from, next) => {
const loggedIn = store.getters[authGetters.loggedIn];
if (loggedIn) {
return next(from.name ? from.fullPath : { name: 'home' });
}

next();
};

export const authRoutes: RouteConfig[] = [
{
path: '/login',
name: AuthRoute.LOGIN,
component: () => import(/* webpackChunkName: "auth" */ './views/login.vue'),
beforeEnter(to, from, next) {
const loggedIn = store.getters[authGetters.loggedIn];
if (loggedIn) {
return next(from.name ? from.fullPath : { name: 'home' });
}

next();
},
beforeEnter: loggedInGuard,
},
{
path: '/logout',
Expand All @@ -36,6 +39,12 @@ export const authRoutes: RouteConfig[] = [
},
},
},
{
path: '/register',
name: AuthRoute.REGISTER,
component: () => import(/* webpackChunkName: "auth" */ './views/register.vue'),
beforeEnter: loggedInGuard,
},
{
path: '/profile',
name: AuthRoute.PROFILE,
Expand Down
17 changes: 13 additions & 4 deletions apps/web/src/modules/auth/views/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<div class="col-sm-8 offset-sm-2 col-md-6 offset-md-3">
<div class="card">
<article class="card-body">
<h4 class="card-title text-center mb-4 mt-1">Sign in</h4>
<hr />
<b-form novalidate @submit.prevent="submit">
<h4 class="card-title text-center mb-4 mt-1">Sign in</h4>
<hr />

<p class="alert alert-danger text-center" v-if="error">{{ error }}</p>
<p class="alert alert-danger text-center" v-if="error">{{ error }}</p>

<b-form novalidate @submit.prevent="submit">
<b-form-group invalid-feedback="Field required" :state="valid.login">
<b-input-group>
<!-- TODO
Expand Down Expand Up @@ -54,6 +54,13 @@
<p class="text-center"><a href="#" class="btn">Forgot password?</a></p>
-->
</b-form>

<div class="text-center">
<p>Don't have an account?</p>
<b-button variant="outline-primary" :to="{ name: authRoute.REGISTER }"
>Create account
</b-button>
</div>
</article>
</div>
</div>
Expand All @@ -63,12 +70,14 @@
<script lang="ts">
import Vue from 'vue';
import { mapActions } from 'vuex';
import { AuthRoute } from '../routes';
import { authActions } from '../store';

export default Vue.extend({
name: 'auth-login',
data() {
return {
authRoute: AuthRoute,
form: {
login: this.$config.demoMode ? 'demo' : '',
password: this.$config.demoMode ? 'demo' : '',
Expand Down
22 changes: 22 additions & 0 deletions apps/web/src/modules/auth/views/register.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div>
register works!
</div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
name: 'register',
components: {},
props: {},
data() {
return {};
},
computed: {},
methods: {},
});
</script>

<style lang="scss" scoped></style>