mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
More Client Fixes (#9002)
* logout should entirely clear localstorage * fix logout, fix social login, remove duplicate home page
This commit is contained in:
@@ -267,8 +267,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logout () {
|
logout () {
|
||||||
localStorage.removeItem('habit-mobile-settings');
|
this.$store.dispatch('auth:logout');
|
||||||
window.location.href = '/logout';
|
|
||||||
},
|
},
|
||||||
showInbox () {
|
showInbox () {
|
||||||
this.$root.$emit('show::modal', 'inbox-modal');
|
this.$root.$emit('show::modal', 'inbox-modal');
|
||||||
|
|||||||
@@ -302,7 +302,13 @@ export default {
|
|||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
},
|
},
|
||||||
async socialAuth (network) {
|
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', {
|
await this.$store.dispatch('auth:socialAuth', {
|
||||||
auth,
|
auth,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default {
|
|||||||
copyingMessage () {
|
copyingMessage () {
|
||||||
this.text = this.copyingMessage.text;
|
this.text = this.copyingMessage.text;
|
||||||
let baseUrl = 'https://habitica.com';
|
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: {
|
methods: {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clearLocalStorage () {
|
clearLocalStorage () {
|
||||||
localStorage.removeItem('habit-mobile-settings');
|
this.$store.dispatch('auth:logout');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
nav.navbar.navbar-toggleable-md.navbar-light.bg-faded
|
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')
|
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
|
span.navbar-toggler-icon
|
||||||
a.navbar-brand(href='#')
|
router-link.nav-link(to="/home")
|
||||||
.logo.svg-icon(v-html="icons.logo")
|
.logo.svg-icon(v-html="icons.logo")
|
||||||
#navbarNav.collapse.navbar-collapse
|
#navbarNav.collapse.navbar-collapse
|
||||||
ul.navbar-nav.float-right
|
ul.navbar-nav.float-right
|
||||||
@@ -631,7 +631,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted () {
|
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: {
|
methods: {
|
||||||
playButtonClick () {
|
playButtonClick () {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
nav.navbar.navbar-inverse.fixed-top.navbar-toggleable-sm
|
nav.navbar.navbar-inverse.fixed-top.navbar-toggleable-sm
|
||||||
.navbar-header
|
.navbar-header
|
||||||
router-link.nav-item(
|
router-link.nav-item(
|
||||||
to='/static/front',
|
to='/home',
|
||||||
)
|
)
|
||||||
.logo.svg-icon(v-html='icons.logo')
|
.logo.svg-icon(v-html='icons.logo')
|
||||||
.collapse.navbar-collapse
|
.collapse.navbar-collapse
|
||||||
|
|||||||
@@ -249,7 +249,6 @@ const router = new VueRouter({
|
|||||||
{ name: 'contact', path: 'contact', component: ContactPage, meta: {requiresLogin: false}},
|
{ name: 'contact', path: 'contact', component: ContactPage, meta: {requiresLogin: false}},
|
||||||
{ name: 'faq', path: 'faq', component: FAQPage, meta: {requiresLogin: false}},
|
{ name: 'faq', path: 'faq', component: FAQPage, meta: {requiresLogin: false}},
|
||||||
{ name: 'features', path: 'features', component: FeaturesPage, 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: 'groupPlans', path: 'group-plans', component: GroupPlansPage, meta: {requiresLogin: false}},
|
||||||
{ name: 'maintenance', path: 'maintenance', component: MaintenancePage, meta: {requiresLogin: false}},
|
{ name: 'maintenance', path: 'maintenance', component: MaintenancePage, meta: {requiresLogin: false}},
|
||||||
{ name: 'maintenance-info', path: 'maintenance-info', component: MaintenanceInfoPage, meta: {requiresLogin: false}},
|
{ name: 'maintenance-info', path: 'maintenance-info', component: MaintenanceInfoPage, meta: {requiresLogin: false}},
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import axios from 'axios';
|
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) {
|
export async function register (store, params) {
|
||||||
let url = '/api/v3/user/auth/local/register';
|
let url = '/api/v3/user/auth/local/register';
|
||||||
let result = await axios.post(url, {
|
let result = await axios.post(url, {
|
||||||
@@ -17,7 +20,7 @@ export async function register (store, params) {
|
|||||||
apiToken: user.apiToken,
|
apiToken: user.apiToken,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
localStorage.setItem('habit-mobile-settings', userLocalData);
|
localStorage.setItem(LOCALSTORAGE_AUTH_KEY, userLocalData);
|
||||||
|
|
||||||
// @TODO: I think we just need analytics here
|
// @TODO: I think we just need analytics here
|
||||||
// Auth.runAuth(res.data._id, res.data.apiToken);
|
// 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
|
// @TODO: I think we just need analytics here
|
||||||
// Auth.runAuth(res.data._id, res.data.apiToken);
|
// 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';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user