From 3d74bff8adf87cb2ac912fda1588ec329db6bded Mon Sep 17 00:00:00 2001 From: Ilya Batuev Date: Tue, 5 Nov 2024 19:40:33 +0000 Subject: [PATCH 1/2] changed registration and login in oauth condition --- src/components/IrdomAuthButton.vue | 2 -- src/router/auth.ts | 15 ++++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/IrdomAuthButton.vue b/src/components/IrdomAuthButton.vue index eb580cf0..6d4212d8 100644 --- a/src/components/IrdomAuthButton.vue +++ b/src/components/IrdomAuthButton.vue @@ -28,10 +28,8 @@ onMounted(async () => { }); async function clickHandler() { - console.log('кликнул', props.button.link, props.unlink); if (props.unlink) { await apiClient.DELETE(`/auth/${props.button.link}`); - console.log('deleted', props.button.link); location.reload(); // TODO: придумать нормальное решение } else if (authUrl.value) { window.open(authUrl.value, '_self'); diff --git a/src/router/auth.ts b/src/router/auth.ts index 1e6dbd9f..42031152 100644 --- a/src/router/auth.ts +++ b/src/router/auth.ts @@ -46,9 +46,7 @@ export const authHandler: NavigationGuard = async to => { if (to.path.startsWith('/auth/oauth-authorized')) { const methodLink = to.params.method; - console.log(methodLink, profileStore.isUserLogged); if (!isAuthMethod(methodLink)) { - console.log('failed', methodLink); return { path: '/auth/error', query: { text: 'Метод авторизации не существует', from: 'oauth' }, @@ -57,7 +55,6 @@ export const authHandler: NavigationGuard = async to => { } if (to.hash === '' && Object.keys(to.query).length === 0) { - console.log('Нет параметров входа', methodLink); return { path: '/auth/error', query: { text: 'Отсутствуют параметры входа', from: 'oauth' }, @@ -65,24 +62,22 @@ export const authHandler: NavigationGuard = async to => { }; } - const { data, response, error } = profileStore.isUserLogged - ? await apiClient.POST(`/auth/${methodLink}/registration`, { + const { data, response } = profileStore.isUserLogged + ? await apiClient.POST(`/auth/${methodLink}/login`, { body: { ...to.query } }) + : await apiClient.POST(`/auth/${methodLink}/registration`, { body: { ...to.query, session_name: navigator.userAgent ?? UNKNOWN_DEVICE, }, - }) - : await apiClient.POST(`/auth/${methodLink}/login`, { body: { ...to.query } }); + }); if (response.ok && data?.token) { - console.log('Успешно вошел', methodLink); LocalStorage.set(LocalStorageItem.Token, data.token); profileStore.updateToken(); toastStore.push({ title: 'Вы успешно вошли в аккаунт' }); return { path: '/profile', replace: true }; } else { if (response.status === 401) { - console.log('401 произошла', response, data, error); const id_token = data?.token; if (typeof id_token !== 'string') { @@ -99,7 +94,6 @@ export const authHandler: NavigationGuard = async to => { } if (response.status === 422) { - console.log('422 произошла'); return { path: '/auth/error', query: { text: 'Выбран неверный аккаунт', from: 'oauth' }, @@ -108,7 +102,6 @@ export const authHandler: NavigationGuard = async to => { } if (response.status === 409) { - console.log('409 произошла'); return { path: '/auth/error', query: { text: 'Аккаунт с такими данными уже существуют', from: 'oauth' }, From 1e7813c3e3867ea425b5bb425994e394f98e1f9c Mon Sep 17 00:00:00 2001 From: Ilya Batuev Date: Tue, 5 Nov 2024 19:42:14 +0000 Subject: [PATCH 2/2] removed unused console logs --- src/views/profile/ProfileEditAuthView.vue | 2 -- src/views/profile/ProfileView.vue | 1 - 2 files changed, 3 deletions(-) diff --git a/src/views/profile/ProfileEditAuthView.vue b/src/views/profile/ProfileEditAuthView.vue index f4b2c7c9..bc10e315 100644 --- a/src/views/profile/ProfileEditAuthView.vue +++ b/src/views/profile/ProfileEditAuthView.vue @@ -20,9 +20,7 @@ onMounted(async () => { profileStore.updateToken(history.state.token); delete history.state.token; } - console.log(profileStore.authMethods); AuthApi.getMe(['auth_methods']); - console.log(profileStore.authMethods); }); const canLinked = computed(() => diff --git a/src/views/profile/ProfileView.vue b/src/views/profile/ProfileView.vue index c6d6e786..fdb5aec5 100644 --- a/src/views/profile/ProfileView.vue +++ b/src/views/profile/ProfileView.vue @@ -18,7 +18,6 @@ const route = useRoute(); const toolbar = useToolbar(); const isOwnProfile = !('id' in route.params) || route.params.id === undefined; -console.log(isOwnProfile); const buttons: ToolbarActionItem[] = [];