From 30fc05870b25574f1da8169fe640e59c4650111d Mon Sep 17 00:00:00 2001 From: Vijayee Kulkaa Date: Fri, 17 Feb 2017 12:04:10 -0500 Subject: [PATCH 1/2] Sign Up View --- frontend/simple/js/backend/index.js | 1 + frontend/simple/js/database.js | 13 ++++ frontend/simple/js/state.js | 8 ++- frontend/simple/views/CreateGroup.vue | 2 +- frontend/simple/views/NavBar.vue | 93 ++++++++++++++++++++------- frontend/simple/views/SignUp.vue | 79 ++++++++++++++++------- test/frontend.js | 62 +++++++++++++++++- 7 files changed, 206 insertions(+), 52 deletions(-) diff --git a/frontend/simple/js/backend/index.js b/frontend/simple/js/backend/index.js index 18ad65e67c..9fc513e7cd 100644 --- a/frontend/simple/js/backend/index.js +++ b/frontend/simple/js/backend/index.js @@ -4,3 +4,4 @@ import {HapiBackend} from './hapi' export default new HapiBackend() + diff --git a/frontend/simple/js/database.js b/frontend/simple/js/database.js index a6f0807f63..ed2df47341 100644 --- a/frontend/simple/js/database.js +++ b/frontend/simple/js/database.js @@ -81,3 +81,16 @@ export function saveSettings (state: Object): Promise<*> { export function loadSettings (): Promise { return appSettings.getItem('testUser') } +// ======================= +// Store login information +// ======================= +const loginInfo = localforage.createInstance({ + name: 'Group Income', + storeName: 'Login Information' +}) +export function storeLogin (identity: string, hash: string): Promise { + return loginInfo.setItem(identity, hash) +} +export function retrieveLogin (identity: string): Promise { + return loginInfo.getItem(identity) +} diff --git a/frontend/simple/js/state.js b/frontend/simple/js/state.js index 763c9fae62..63f207e28e 100644 --- a/frontend/simple/js/state.js +++ b/frontend/simple/js/state.js @@ -27,12 +27,18 @@ const state = { currentGroupId: null, contracts: {}, // contracts we've successfully subscribed to whitelist: [], // contracts we're expecting to subscribe to - loggedIn: true// TODO: properly handle this + loggedIn: false// TODO: properly handle this } // Mutations must be synchronous! Never call these directly! // http://vuex.vuejs.org/en/mutations.html const mutations = { + login (state, user) { + state.loggedIn = user + }, + logout (state) { + state.loggedIn = false + }, applyAction (state, {action, contractId}) { action.apply(store, contractId, Vue) }, diff --git a/frontend/simple/views/CreateGroup.vue b/frontend/simple/views/CreateGroup.vue index ddeed3efac..6122926d6c 100644 --- a/frontend/simple/views/CreateGroup.vue +++ b/frontend/simple/views/CreateGroup.vue @@ -121,7 +121,7 @@ export default { memberRemovalPercentage: this.memberRemovalPercentage, incomeProvided: this.incomeProvided, contributionPrivacy: this.contributionPrivacy, - founderHashKey: 'alsdfjlskdfjaslkfjsldkfj' + founderHashKey: this.$store.state.loggedIn }) let hash = entry.toHash() await backend.subscribe(hash) diff --git a/frontend/simple/views/NavBar.vue b/frontend/simple/views/NavBar.vue index bc6b3ba93d..30e26f77d5 100644 --- a/frontend/simple/views/NavBar.vue +++ b/frontend/simple/views/NavBar.vue @@ -26,8 +26,8 @@ -