mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* Added session check before route changes, but express isn't finding route * Added a logout component. Changed route to logout on server. Typing 'logout' in URL will logout of Vue + Express * Removed commented text from previous version * Updated logout function to comply with formatting and eliminate unused blocks * Added package-lock.json back * package-lock.json * recreated package-lock file * fix(auth): allow logout from direct visit to /logout path * fix(merge): clean up more misc changes * fix(merge): remove extra file
This commit is contained in:
@@ -62,7 +62,7 @@ module.exports = {
|
|||||||
target: DEV_BASE_URL,
|
target: DEV_BASE_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/logout': {
|
'/logout-server': {
|
||||||
target: DEV_BASE_URL,
|
target: DEV_BASE_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
|
|||||||
13
website/client/components/auth/logout.vue
Normal file
13
website/client/components/auth/logout.vue
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
components: {},
|
||||||
|
methods: {
|
||||||
|
async logout () {
|
||||||
|
return await this.$store.dispatch('auth:logout');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.logout();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -27,6 +27,7 @@ const PrivacyPage = () => import(/* webpackChunkName: "static" */'./components/s
|
|||||||
const TermsPage = () => import(/* webpackChunkName: "static" */'./components/static/terms');
|
const TermsPage = () => import(/* webpackChunkName: "static" */'./components/static/terms');
|
||||||
|
|
||||||
const RegisterLoginReset = () => import(/* webpackChunkName: "auth" */'./components/auth/registerLoginReset');
|
const RegisterLoginReset = () => import(/* webpackChunkName: "auth" */'./components/auth/registerLoginReset');
|
||||||
|
const Logout = () => import(/* webpackChunkName: "auth" */'./components/auth/logout');
|
||||||
|
|
||||||
// User Pages
|
// User Pages
|
||||||
// const StatsPage = () => import(/* webpackChunkName: "user" */'./components/userMenu/stats');
|
// const StatsPage = () => import(/* webpackChunkName: "user" */'./components/userMenu/stats');
|
||||||
@@ -105,6 +106,7 @@ const router = new VueRouter({
|
|||||||
routes: [
|
routes: [
|
||||||
{ name: 'register', path: '/register', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
{ name: 'register', path: '/register', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
||||||
{ name: 'login', path: '/login', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
{ name: 'login', path: '/login', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
||||||
|
{ name: 'logout', path: '/logout', component: Logout },
|
||||||
{ name: 'resetPassword', path: '/reset-password', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
{ name: 'resetPassword', path: '/reset-password', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
||||||
{ name: 'tasks', path: '/', component: UserTasks },
|
{ name: 'tasks', path: '/', component: UserTasks },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,5 +68,5 @@ export async function socialAuth (store, params) {
|
|||||||
export function logout () {
|
export function logout () {
|
||||||
localStorage.removeItem(LOCALSTORAGE_AUTH_KEY);
|
localStorage.removeItem(LOCALSTORAGE_AUTH_KEY);
|
||||||
localStorage.removeItem(LOCALSTORAGE_SOCIAL_AUTH_KEY);
|
localStorage.removeItem(LOCALSTORAGE_SOCIAL_AUTH_KEY);
|
||||||
window.location.href = '/logout';
|
window.location.href = '/logout-server';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ api.resetPasswordSetNewOne = {
|
|||||||
// Logout the user from the website.
|
// Logout the user from the website.
|
||||||
api.logout = {
|
api.logout = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/logout',
|
url: '/logout-server',
|
||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
if (req.logout) req.logout(); // passportjs method
|
if (req.logout) req.logout(); // passportjs method
|
||||||
req.session = null;
|
req.session = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user