summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2021-09-04 18:09:53 +0900
committerGitHub <noreply@github.com>2021-09-04 18:09:53 +0900
commit48f46333f8e3fac771226a7c0d42452de1ec6f7e (patch)
tree3d1064e3dba1337b9647d97964eb34045ecdf54a /src
parent藍モード (#7687) (diff)
downloadmisskey-48f46333f8e3fac771226a7c0d42452de1ec6f7e.tar.gz
misskey-48f46333f8e3fac771226a7c0d42452de1ec6f7e.tar.bz2
misskey-48f46333f8e3fac771226a7c0d42452de1ec6f7e.zip
サインアップ・ログアウト周りの怪しい挙動を修正 (#7750)
* fix #7749 * fix * fix logout behavior when there is no push subscription * fix logout behavior when there is no push subscription 2 * clean up service worker registration * fix lint * remove submodules
Diffstat (limited to 'src')
-rw-r--r--src/client/account.ts38
-rwxr-xr-xsrc/client/components/signin.vue6
-rw-r--r--src/client/components/signup.vue4
-rw-r--r--src/client/pages/welcome.setup.vue2
4 files changed, 32 insertions, 18 deletions
diff --git a/src/client/account.ts b/src/client/account.ts
index ee1d845493..e469bae5a2 100644
--- a/src/client/account.ts
+++ b/src/client/account.ts
@@ -1,4 +1,4 @@
-import { get, set } from '@client/scripts/idb-proxy';
+import { del, get, set } from '@client/scripts/idb-proxy';
import { reactive } from 'vue';
import { apiUrl } from '@client/config';
import { waiting } from '@client/os';
@@ -26,21 +26,33 @@ export async function signout() {
//#region Remove account
const accounts = await getAccounts();
accounts.splice(accounts.findIndex(x => x.id === $i.id), 1);
- set('accounts', accounts);
+
+ if (accounts.length > 0) await set('accounts', accounts);
+ else await del('accounts');
//#endregion
- //#region Remove push notification registration
+ //#region Remove service worker registration
try {
- const registration = await navigator.serviceWorker.ready;
- const push = await registration.pushManager.getSubscription();
- if (!push) return;
- await fetch(`${apiUrl}/sw/unregister`, {
- method: 'POST',
- body: JSON.stringify({
- i: $i.token,
- endpoint: push.endpoint,
- }),
- });
+ if (navigator.serviceWorker.controller) {
+ const registration = await navigator.serviceWorker.ready;
+ const push = await registration.pushManager.getSubscription();
+ if (push) {
+ await fetch(`${apiUrl}/sw/unregister`, {
+ method: 'POST',
+ body: JSON.stringify({
+ i: $i.token,
+ endpoint: push.endpoint,
+ }),
+ });
+ }
+ }
+
+ if (accounts.length === 0) {
+ await navigator.serviceWorker.getRegistrations()
+ .then(registrations => {
+ return Promise.all(registrations.map(registration => registration.unregister()));
+ });
+ }
} catch (e) {}
//#endregion
diff --git a/src/client/components/signin.vue b/src/client/components/signin.vue
index 0094038fb6..c051288d0a 100755
--- a/src/client/components/signin.vue
+++ b/src/client/components/signin.vue
@@ -111,7 +111,9 @@ export default defineComponent({
onLogin(res) {
if (this.autoSet) {
- login(res.i);
+ return login(res.i);
+ } else {
+ return;
}
},
@@ -144,7 +146,7 @@ export default defineComponent({
});
}).then(res => {
this.$emit('login', res);
- this.onLogin(res);
+ return this.onLogin(res);
}).catch(err => {
if (err === null) return;
os.dialog({
diff --git a/src/client/components/signup.vue b/src/client/components/signup.vue
index d584b97209..d332274111 100644
--- a/src/client/components/signup.vue
+++ b/src/client/components/signup.vue
@@ -178,14 +178,14 @@ export default defineComponent({
'hcaptcha-response': this.hCaptchaResponse,
'g-recaptcha-response': this.reCaptchaResponse,
}).then(() => {
- os.api('signin', {
+ return os.api('signin', {
username: this.username,
password: this.password
}).then(res => {
this.$emit('signup', res);
if (this.autoSet) {
- login(res.i);
+ return login(res.i);
}
});
}).catch(() => {
diff --git a/src/client/pages/welcome.setup.vue b/src/client/pages/welcome.setup.vue
index de844ece1c..d0091bef67 100644
--- a/src/client/pages/welcome.setup.vue
+++ b/src/client/pages/welcome.setup.vue
@@ -53,7 +53,7 @@ export default defineComponent({
username: this.username,
password: this.password,
}).then(res => {
- login(res.i);
+ return login(res.token);
}).catch(() => {
this.submitting = false;