* Fixed cursor clicking ToDo lists clicking to early
* Added login form to home page with focus on load * Tags update after editing tags from title card * Fixed uploading of images/files * Fixed images not appearing when opening images tab * Search hits all categories on search, like archived * Got rid of brand icons to reduce size * Got rid of DiffPatchMatch and Crypto from note input panel to reduce size * Disabled animation on io events so they don't annoy the shit out of people on other computers
This commit is contained in:
112
client/src/components/LoginFormComponent.vue
Normal file
112
client/src/components/LoginFormComponent.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
|
||||
<div v-on:keyup.enter="submit()">
|
||||
|
||||
<div v-if="!thin" class="ui large form">
|
||||
<div class="field">
|
||||
<div class="ui input">
|
||||
<input ref="nameForm" v-model="username" type="text" name="email" placeholder="Username or E-mail address" autofocus>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui input">
|
||||
<input v-model="password" type="password" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
<div :class="{ 'disabled':(username.length == 0 || password.length == 0)}" v-on:click="submit" class="ui massive compact fluid green submit button">Sign Up / Login</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="thin" class="ui small form">
|
||||
<div class="fields">
|
||||
<div class="six wide field">
|
||||
<div class="ui input">
|
||||
<input ref="nameForm" v-model="username" type="text" name="email" placeholder="Username or E-mail address" autofocus>
|
||||
</div>
|
||||
</div>
|
||||
<div class="six wide field">
|
||||
<div class="ui input">
|
||||
<input v-model="password" type="password" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<div :class="{ 'disabled':(username.length == 0 || password.length == 0)}" v-on:click="submit" class="ui fluid green submit button">Sign Up / Login</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
props:[ 'thin' ],
|
||||
mounted() {
|
||||
|
||||
//Focus on login form on desktop
|
||||
if(!this.$store.getters.getIsUserOnMobile){
|
||||
this.$refs.nameForm.focus()
|
||||
}
|
||||
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
enabled: false,
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit(){
|
||||
|
||||
//Both fields are required
|
||||
if(this.username <= 0){
|
||||
return false
|
||||
}
|
||||
if(this.password <= 0){
|
||||
return false
|
||||
}
|
||||
|
||||
let vm = this
|
||||
|
||||
let data = {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}
|
||||
|
||||
axios.post('/api/user/login', data)
|
||||
.then(response => {
|
||||
if(response.data.success){
|
||||
|
||||
const token = response.data.token
|
||||
const username = response.data.username
|
||||
const masterKey = response.data.masterKey
|
||||
|
||||
this.$store.commit('setLoginToken', {token, username, masterKey})
|
||||
|
||||
//Setup socket io after user logs in
|
||||
this.$io.emit('user_connect', token)
|
||||
|
||||
//Redirect user to notes section after login
|
||||
this.$router.push('/notes')
|
||||
} else {
|
||||
// this.password = ''
|
||||
this.$bus.$emit('notification', 'Incorrect Username or Password')
|
||||
vm.$store.commit('destroyLoginToken')
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$bus.$emit('notification', 'Incorrect Username or Password')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user