* Added Much better session Management, key updating and deleting

* Force reload of JS if app numbers dont match
* Added cool tag display on side of note
* Cleaned up a bunch of code and tweaked little things to be better
This commit is contained in:
Max G
2020-06-15 09:02:20 +00:00
parent 56d4664d0d
commit e4fae23623
18 changed files with 333 additions and 270 deletions

View File

@@ -98,13 +98,15 @@
//Login user if we have a valid token
if(data && data.token && data.token.length > 0){
const token = data.token
const username = this.username
//Set username to local session
this.$store.commit('setUsername', this.username)
this.$store.commit('setLoginToken', {token, username})
const token = data.token
//Setup socket io after user logs in
axios.defaults.headers.common['authorizationtoken'] = token
this.$io.emit('user_connect', token)
localStorage.setItem('loginToken', token)
//Redirect user to notes section after login
this.$router.push('/notes')
@@ -113,7 +115,7 @@
register(){
if( this.username.length == 0 || this.password.length == 0 ){
this.$bus.$emit('notification', 'Username and Password Required')
this.$bus.$emit('notification', 'Unable to Sign Up - Username and Password Required')
return
}
@@ -121,19 +123,19 @@
.then(({data}) => {
if(data == false){
this.$bus.$emit('notification', 'Username already in use')
this.$bus.$emit('notification', 'Unable to Sign Up - Username already in use')
}
this.finalizeLogin(data)
})
.catch(error => {
this.$bus.$emit('notification', 'Username already in use')
this.$bus.$emit('notification', 'Unable to Sign Up - Username already in use')
})
},
login(){
if( this.username.length == 0 || this.password.length == 0 ){
this.$bus.$emit('notification', 'Username and Password Required')
this.$bus.$emit('notification', 'Unable to Login - Username and Password Required')
return
}
@@ -141,13 +143,13 @@
.then(({data}) => {
if(data == false){
this.$bus.$emit('notification', 'Incorrect Username or Password')
this.$bus.$emit('notification', 'Unable to Login - Incorrect Username or Password')
}
this.finalizeLogin(data)
})
.catch(error => {
this.$bus.$emit('notification', 'Incorrect Username or Password')
this.$bus.$emit('notification', 'Unable to Login - Incorrect Username or Password')
})
}
}