浏览代码

update login method

pull/342/head
Guillaume Vincent 8 年前
父节点
当前提交
1a8bfd5c29
共有 4 个文件被更改,包括 19 次插入17 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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


正在加载...
取消
保存