From 80eedf744944769c8ba9bbdccc2aa7dad06b2151 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 20 Mar 2020 13:56:22 +0900 Subject: 連携ログインができないのなどを修正 (#6162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 連携ログインができないのを修正 * Cookie名変更, セッションに * igiはやっぱり非セッションCookieで * 2回目以降Discordログインできなくなるのを修正 --- src/client/mios.ts | 7 ++++++- src/client/pages/my-settings/integration.vue | 7 +++---- src/client/store.ts | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/client') diff --git a/src/client/mios.ts b/src/client/mios.ts index c2ba8ac5cd..aa2b202abd 100644 --- a/src/client/mios.ts +++ b/src/client/mios.ts @@ -123,7 +123,12 @@ export default class MiOS extends EventEmitter { }); } else { // Get token from localStorage - const i = localStorage.getItem('i'); + let i = localStorage.getItem('i'); + + // 連携ログインの場合用にCookieを参照する + if (i == null || i === 'null') { + i = (document.cookie.match(/igi=(\w+)/) || [null, null])[1]; + } fetchme(i, me => { if (me) { diff --git a/src/client/pages/my-settings/integration.vue b/src/client/pages/my-settings/integration.vue index 742d432018..3dd7783f12 100644 --- a/src/client/pages/my-settings/integration.vue +++ b/src/client/pages/my-settings/integration.vue @@ -70,11 +70,10 @@ export default Vue.extend({ }, mounted() { - if (!document.cookie.match(/i=(\w+)/)) { - document.cookie = `i=${this.$store.state.i.token}; path=/;` + - ` domain=${document.location.hostname}; max-age=31536000;` + + document.cookie = `igi=${this.$store.state.i.token}; path=/;` + + ` max-age=31536000;` + (document.location.protocol.startsWith('https') ? ' secure' : ''); - } + this.$watch('integrations', () => { if (this.integrations.twitter) { if (this.twitterForm) this.twitterForm.close(); diff --git a/src/client/store.ts b/src/client/store.ts index 3064cfdec7..8ded1ba00d 100644 --- a/src/client/store.ts +++ b/src/client/store.ts @@ -101,6 +101,7 @@ export default (os: MiOS) => new Vuex.Store({ ctx.commit('settings/init', {}); ctx.commit('deviceUser/init', {}); localStorage.removeItem('i'); + document.cookie = `igi=; path=/`; }, async switchAccount(ctx, i) { -- cgit v1.2.3-freya