summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-11-28 16:19:02 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-11-28 16:19:02 +0900
commit4bbb7eded3abf6045ef60971b21eed7d08afe946 (patch)
treea4c0ae1a15236ca16f255c150559f01b6223e1cb /src
parentUpdate signin.ts (diff)
downloadsharkey-4bbb7eded3abf6045ef60971b21eed7d08afe946.tar.gz
sharkey-4bbb7eded3abf6045ef60971b21eed7d08afe946.tar.bz2
sharkey-4bbb7eded3abf6045ef60971b21eed7d08afe946.zip
Cookieを使わないように
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/views/components/signin.vue3
-rw-r--r--src/client/app/mios.ts4
-rw-r--r--src/client/app/safe.js8
-rw-r--r--src/client/app/store.ts1
-rw-r--r--src/server/api/common/signin.ts3
5 files changed, 7 insertions, 12 deletions
diff --git a/src/client/app/common/views/components/signin.vue b/src/client/app/common/views/components/signin.vue
index c1a7522b00..dd3d979852 100644
--- a/src/client/app/common/views/components/signin.vue
+++ b/src/client/app/common/views/components/signin.vue
@@ -67,7 +67,8 @@ export default Vue.extend({
username: this.username,
password: this.password,
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
- }, true).then(() => {
+ }, true).then(res => {
+ localStorage.setItem('i', res.i);
location.reload();
}).catch(() => {
alert(this.$t('login-failed'));
diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts
index 5ed4dfd4db..fad60f4137 100644
--- a/src/client/app/mios.ts
+++ b/src/client/app/mios.ts
@@ -190,8 +190,8 @@ export default class MiOS extends EventEmitter {
this.store.dispatch('mergeMe', freshData);
});
} else {
- // Get token from cookie
- const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1];
+ // Get token from cookie or localStorage
+ const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1] || localStorage.getItem('i');
fetchme(i, me => {
if (me) {
diff --git a/src/client/app/safe.js b/src/client/app/safe.js
index 026fc66c6e..3e2e5ae579 100644
--- a/src/client/app/safe.js
+++ b/src/client/app/safe.js
@@ -11,11 +11,3 @@ if (!('fetch' in window)) {
'Your browser (or your OS) seems outdated. ' +
'To run Misskey, please update your browser to latest version or try other browsers.');
}
-
-// Check whether cookie enabled
-if (!navigator.cookieEnabled) {
- alert(
- 'Misskeyを利用するにはCookieを有効にしてください。' +
- '\n\n' +
- 'To use Misskey, please enable Cookie.');
-}
diff --git a/src/client/app/store.ts b/src/client/app/store.ts
index 0a16a71a2a..a498b0138f 100644
--- a/src/client/app/store.ts
+++ b/src/client/app/store.ts
@@ -129,6 +129,7 @@ export default (os: MiOS) => new Vuex.Store({
logout(ctx) {
ctx.commit('updateI', null);
document.cookie = `i=; domain=${hostname}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
+ localStorage.removeItem('i');
},
mergeMe(ctx, me) {
diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts
index ddfd5f2bba..45a42e288d 100644
--- a/src/server/api/common/signin.ts
+++ b/src/server/api/common/signin.ts
@@ -21,6 +21,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
ctx.redirect(config.url);
} else {
- ctx.status = 204;
+ ctx.body = { i: user.token };
+ ctx.status = 200;
}
}