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

add authentication #158

Merged
merged 1 commit into from
Dec 10, 2018
Merged
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
4 changes: 3 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build": "node build/build.js"
},
"dependencies": {
"@vuetify/vuex-cognito-module": "^0.4.0",
"axios": "0.18.0",
"js-base64": "2.4.9",
"toml": "2.3.3",
Expand All @@ -24,7 +25,8 @@
"vue-router": "3.0.2",
"vue-socket.io": "3.0.4",
"vue-tour": "^1.1.0",
"vuetify": "^1.3.12"
"vuetify": "^1.3.12",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "7.2.6",
Expand Down
Binary file added dashboard/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions dashboard/src/components/auth/BaseBtn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<VBtn
class="white--text"
color="indigo"
depressed
v-bind="$attrs"
v-on="$listeners"
>
<slot />
</VBtn>
</template>

<script>
export default {
inheritAttrs: false
}
</script>

<style lang="scss" scoped>
.v-btn {
border-radius: 4px;
text-transform: none;
}
</style>
15 changes: 15 additions & 0 deletions dashboard/src/components/auth/BaseCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<VCard
class="elevation-4"
v-bind="$attrs"
v-on="$listeners"
>
<slot />
</VCard>
</template>

<style lang="scss" scoped>
.v-card {
border-radius: 6px;
}
</style>
33 changes: 33 additions & 0 deletions dashboard/src/components/auth/BaseHeading.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div
class="mb-4"
v-bind="$attrs"
v-on="$listeners"
>
<h1
class="headline"
v-text="text"
/>
<div
class="subheading"
v-text="sub"
/>
</div>
</template>

<script>
export default {
inheritAttrs: false,

props: {
sub: {
type: String,
default: undefined
},
text: {
type: String,
default: undefined
}
}
}
</script>
38 changes: 38 additions & 0 deletions dashboard/src/components/auth/BaseText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<Component
:is="component"
:target="$attrs.href ? '_blank' : undefined"
class="indigo--text subheading font-weight-bold"
v-bind="$attrs"
v-on="$listeners"
>
<slot />
<VIcon
v-if="$attrs.href"
color="indigo lighten-1"
small
>
mdi-open-in-new
</VIcon>
</Component>
</template>

<script>
export default {
inheritAttrs: false,

computed: {
component () {
return this.$attrs.to
? 'router-link'
: this.$attrs.href ? 'a' : 'span'
}
}
}
</script>

<style lang="scss" scoped>
a {
text-decoration: none;
}
</style>
70 changes: 70 additions & 0 deletions dashboard/src/components/auth/Email.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<div>
<BaseHeading
class="text-xs-center"
text="Sign in"
sub="to continue to Auto AI"
/>

<VTextField
v-model="internalValue"
autofocus
label="Email or phone"
name="email"
/>

<BaseText>Forgot email?</BaseText>

<div class="my-5">
<div class="subheading">
Want to learn more about Auto AI?
</div>
<BaseText href="https://hub.autoai.org">
Learn more
</BaseText>
</div>

<VLayout align-center>
<VFlex xs8>
<BaseText to="/auth/signup">
Create account
</BaseText>
</VFlex>
<VFlex text-xs-right>
<BaseBtn
:disabled="!internalValue"
class="ma-0"
@click="$emit('next')"
>
Next
</BaseBtn>
</VFlex>
</VLayout>
</div>
</template>

<script>
// Utilities
import {
mapMutations
} from 'vuex'

export default {
name: 'Email',

computed: {
internalValue: {
get () {
return this.$store.state.email
},
set (val) {
this.setEmail(val)
}
}
},

methods: {
...mapMutations(['setEmail'])
}
}
</script>
24 changes: 24 additions & 0 deletions dashboard/src/components/auth/Footer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<VLayout
caption
mt-4
>
<VFlex>
English (United States)
</VFlex>
<VSpacer />
<VFlex shrink>
<VLayout justify-space-between>
<strong class="mx-2">
Help
</strong>
<strong class="mx-2">
Privacy
</strong>
<strong class="mx-2">
Terms
</strong>
</VLayout>
</VFlex>
</VLayout>
</template>
134 changes: 134 additions & 0 deletions dashboard/src/components/auth/Password.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<template>
<div>
<div class="text-xs-center">
<VChip
class="mb-3"
outline
@click="$emit('prev')"
>
<VIcon
color="primary"
left
>
mdi-account-circle
</VIcon>
<span
class="body-2"
v-text="email"
/>
<VIcon
color="black"
right
>
mdi-chevron-down
</VIcon>
</VChip>
</div>

<VTextField
v-model="internalValue"
:append-icon="show ? 'mdi-eye' : 'mdi-eye-off'"
:type="show ? 'text' : 'password'"
class="mb-3"
label="Password"
name="password"
@click:append="show = !show"
/>

<div class="text-xs-left">
<VLayout
align-center
justify-space-between
>
<BaseText>
Forgot password?
</BaseText>

<VBtn
:disabled="!internalValue"
:loading="isLoading"
class="text-capitalize ma-0"
color="indigo darken-1"
depressed
@click="submit"
>
Next
</VBtn>
</VLayout>
</div>
</div>
</template>

<script>
// Utilities
import {
mapActions,
mapMutations,
mapState
} from 'vuex'

export default {
data: () => ({
show: false
}),

computed: {
...mapState([
'email',
'password',
'isLoading'
]),
internalValue: {
get () {
return this.$store.state.password
},
set (val) {
this.setPassword(val)
}
}
},

methods: {
...mapActions('cognito', ['signInUser']),
...mapMutations([
'setEmail',
'setPassword',
'setIsLoading',
'setSnackbar'
]),
submit () {
this.hasError = false
this.setIsLoading(true)
this.signInUser({
username: this.email,
password: this.password
})
.then(() => {
this.setSnackbar({
type: 'success',
msg: `Successfully signed in user ${this.email}`
})

this.setEmail('')
this.$router.replace('/home')
})
.catch(res => {
this.setSnackbar({
type: 'error',
msg: res
})
})
.finally(() => {
this.setIsLoading(false)
this.setPassword('')
})
}
}
}
</script>

<style lang="scss">
.v-chip__content {
cursor: pointer !important;
}
</style>
Loading