Skip to content

Commit

Permalink
fixed logging in with oauth? (#245)
Browse files Browse the repository at this point in the history
## Изменения
Нашел ошибку в router/auth.ts, теперь должно быть можно залогиниться с
помощью оаутх
  • Loading branch information
BatuevIO authored Sep 30, 2024
1 parent 97c9230 commit 7bb3e89
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/router/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const authHandler: NavigationGuard = async to => {

if (to.path.startsWith('/auth/oauth-authorized')) {
const methodLink = to.params.method;
console.log(methodLink);
console.log(methodLink, profileStore.isUserLogged);
if (!isAuthMethod(methodLink)) {
console.log('failed', methodLink);
return {
Expand All @@ -65,12 +65,14 @@ export const authHandler: NavigationGuard = async to => {
};
}

const { data, response } = await apiClient.POST(`/auth/${methodLink}/registration`, {
body: {
...to.query,
session_name: navigator.userAgent ?? UNKNOWN_DEVICE,
},
});
const { data, response } = profileStore.isUserLogged
? 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);
Expand Down

0 comments on commit 7bb3e89

Please sign in to comment.