Sfoglia il codice sorgente

update login method

pull/342/head
Guillaume Vincent 8 anni fa
parent
commit
1a8bfd5c29
4 ha cambiato i file con 19 aggiunte e 17 eliminazioni
  1. +7
    -5
      src/components/Login.vue
  2. +2
    -2
      src/components/Menu.vue
  3. +1
    -0
      src/main.js
  4. +9
    -10
      src/store.js

+ 7
- 5
src/components/Login.vue Vedi File

@@ -108,20 +108,22 @@
}, 3000);
},
login(){
if (!this.user.email || !this.user.password || !this.baseURL) {
var baseURL = this.baseURL;
var email = this.user.email;
if (!email || !this.user.password || !baseURL) {
this.showErrorMessage('email, password and url ');
return;
}
this.auth.login(this.user, this.baseURL)
this.auth.login(this.user, baseURL)
.then(()=> {
this.storage.save({baseURL: this.baseURL});
this.$store.dispatch('userAuthenticated', {email: this.user.email});
this.storage.save({baseURL: baseURL, email: email});
this.$store.dispatch('userAuthenticated', {email: email});
this.$store.dispatch('go', 'index');
this.$store.dispatch('loadPasswords');
})
.catch(err => {
if (err.response === undefined) {
if (this.baseURL === "https://lesspass.com") {
if (baseURL === "https://lesspass.com") {
this.showErrorMessage('LessPass Database is not running. Sorry for the inconvenience.');
} else {
this.showErrorMessage('Your LessPass Database is not running');


+ 2
- 2
src/components/Menu.vue Vedi File

@@ -20,7 +20,7 @@
<div class="btn-group">
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" style="background-color:transparent; padding:0;">
{{user.email}}
{{email}}
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button" v-on:click="go('passwords')">Passwords</button>
@@ -71,7 +71,7 @@
'page',
'isAuthenticated',
'isGuest',
'user'
'email'
])
}
</script>

+ 1
- 0
src/main.js Vedi File

@@ -9,6 +9,7 @@ import Store from './store'
import Storage from './api/storage';

const storage = new Storage();
console.log(storage.json())
const store = Store(storage.json());

new Vue({


+ 9
- 10
src/store.js Vedi File

@@ -12,9 +12,8 @@ const passwords = new HTTP('passwords', storage);

const state = {
page: 'index',
user: {
authenticated: auth.isAuthenticated()
},
authenticated: auth.isAuthenticated(),
email: '',
passwords: [],
currentPassword: {}
};
@@ -27,7 +26,7 @@ const mutations = {
state.page = page
},
logout(state){
state.user = {authenticated: false};
state.authenticated = false;
state.page = 'login';
state.currentPassword = {
site: '',
@@ -44,8 +43,8 @@ const mutations = {
state.passwords = [];
},
userAuthenticated(state, user){
state.user.authenticated = true;
state.user.email = user.email;
state.authenticated = true;
state.email = user.email;
},
loadPasswords(state, passwords){
state.passwords = passwords
@@ -69,17 +68,17 @@ const actions = {

const getters = {
page: state => state.page,
isAuthenticated: state => state.user.authenticated,
isGuest: state => !state.user.authenticated,
isAuthenticated: state => state.authenticated,
isGuest: state => !state.authenticated,
passwords: state => state.passwords,
currentPassword: state => state.currentPassword,
user: state => state.user,
email: state => state.email,
baseURL: state => state.baseURL
};

export default function (config) {
return new Vuex.Store({
state: Object.assign(config, state),
state: Object.assign(state, config),
getters,
actions,
mutations


Caricamento…
Annulla
Salva