More Client Fixes (#9002)

* logout should entirely clear localstorage

* fix logout, fix social login, remove duplicate home page
This commit is contained in:
Matteo Pagliazzi
2017-08-29 16:18:26 +02:00
committed by GitHub
parent 9fc7bae13e
commit 40567fc8d0
8 changed files with 25 additions and 12 deletions

View File

@@ -267,8 +267,7 @@ export default {
},
methods: {
logout () {
localStorage.removeItem('habit-mobile-settings');
window.location.href = '/logout';
this.$store.dispatch('auth:logout');
},
showInbox () {
this.$root.$emit('show::modal', 'inbox-modal');

View File

@@ -302,7 +302,13 @@ export default {
window.location.href = '/';
},
async socialAuth (network) {
let auth = await hello(network).login({scope: 'email'});
const url = window.location.href;
let auth = await hello(network).login({
scope: 'email',
// explicitly pass the redirect url or it might redirect to /home
redirect_uri: url, // eslint-disable-line camelcase
});
await this.$store.dispatch('auth:socialAuth', {
auth,

View File

@@ -46,7 +46,7 @@ export default {
copyingMessage () {
this.text = this.copyingMessage.text;
let baseUrl = 'https://habitica.com';
this.notes = `[${this.copyingMessage.user}](${baseUrl}/static/front/#?memberId=${this.copyingMessage.uuid}) wrote in [${this.groupName}](${baseUrl}/#/options/groups/${this.groupId})`;
this.notes = `[${this.copyingMessage.user}](${baseUrl}/home/#?memberId=${this.copyingMessage.uuid}) wrote in [${this.groupName}](${baseUrl}/#/options/groups/${this.groupId})`;
},
},
methods: {

View File

@@ -48,7 +48,7 @@
},
methods: {
clearLocalStorage () {
localStorage.removeItem('habit-mobile-settings');
this.$store.dispatch('auth:logout');
},
},
};

View File

@@ -7,7 +7,7 @@
nav.navbar.navbar-toggleable-md.navbar-light.bg-faded
button.navbar-toggler.navbar-toggler-right(type='button', data-toggle='collapse', data-target='#navbarNav', aria-controls='navbarNav', aria-expanded='false', aria-label='Toggle navigation')
span.navbar-toggler-icon
a.navbar-brand(href='#')
router-link.nav-link(to="/home")
.logo.svg-icon(v-html="icons.logo")
#navbarNav.collapse.navbar-collapse
ul.navbar-nav.float-right
@@ -631,7 +631,7 @@ export default {
};
},
mounted () {
// Analytics.track({"hitType":"pageview","eventCategory":"page","eventAction":"landing page","page":"/static/front"});
// Analytics.track({"hitType":"pageview","eventCategory":"page","eventAction":"landing page","page":"/home"});
},
methods: {
playButtonClick () {

View File

@@ -2,7 +2,7 @@
nav.navbar.navbar-inverse.fixed-top.navbar-toggleable-sm
.navbar-header
router-link.nav-item(
to='/static/front',
to='/home',
)
.logo.svg-icon(v-html='icons.logo')
.collapse.navbar-collapse

View File

@@ -249,7 +249,6 @@ const router = new VueRouter({
{ name: 'contact', path: 'contact', component: ContactPage, meta: {requiresLogin: false}},
{ name: 'faq', path: 'faq', component: FAQPage, meta: {requiresLogin: false}},
{ name: 'features', path: 'features', component: FeaturesPage, meta: {requiresLogin: false}},
{ name: 'front', path: 'front', component: FrontPage, meta: {requiresLogin: false}},
{ name: 'groupPlans', path: 'group-plans', component: GroupPlansPage, meta: {requiresLogin: false}},
{ name: 'maintenance', path: 'maintenance', component: MaintenancePage, meta: {requiresLogin: false}},
{ name: 'maintenance-info', path: 'maintenance-info', component: MaintenanceInfoPage, meta: {requiresLogin: false}},

View File

@@ -1,5 +1,8 @@
import axios from 'axios';
const LOCALSTORAGE_AUTH_KEY = 'habit-mobile-settings';
const LOCALSTORAGE_SOCIAL_AUTH_KEY = 'hello'; // Used by hello.js for social auth
export async function register (store, params) {
let url = '/api/v3/user/auth/local/register';
let result = await axios.post(url, {
@@ -17,7 +20,7 @@ export async function register (store, params) {
apiToken: user.apiToken,
},
});
localStorage.setItem('habit-mobile-settings', userLocalData);
localStorage.setItem(LOCALSTORAGE_AUTH_KEY, userLocalData);
// @TODO: I think we just need analytics here
// Auth.runAuth(res.data._id, res.data.apiToken);
@@ -47,7 +50,7 @@ export async function login (store, params) {
},
});
localStorage.setItem('habit-mobile-settings', userLocalData);
localStorage.setItem(LOCALSTORAGE_AUTH_KEY, userLocalData);
// @TODO: I think we just need analytics here
// Auth.runAuth(res.data._id, res.data.apiToken);
@@ -79,5 +82,11 @@ export async function socialAuth (store, params) {
},
});
localStorage.setItem('habit-mobile-settings', userLocalData);
localStorage.setItem(LOCALSTORAGE_AUTH_KEY, userLocalData);
}
export function logout () {
localStorage.removeItem(LOCALSTORAGE_AUTH_KEY);
localStorage.removeItem(LOCALSTORAGE_SOCIAL_AUTH_KEY);
window.location.href = '/logout';
}