Skip to content

Commit

Permalink
исправил редирект
Browse files Browse the repository at this point in the history
  • Loading branch information
veglem committed Mar 4, 2024
1 parent 75b323e commit fae2b7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion public/src/modules/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Router {
const notFoundPage = new NotFoundPage(root, config.notFoundPage)
this.registerPage(notFoundPage)

AppDispatcher.dispatch(UserActions.CHECK_USER);
console.log("dispatching")

AppDispatcher.dispatch({type: UserActions.CHECK_USER});
}

registerPage(page) {
Expand Down
4 changes: 4 additions & 0 deletions public/src/stores/user/userStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UserStore {
await this.register(action.payload);
break;
case UserActions.CHECK_USER:
console.log("action handled")
await this.checkUser();
break;
}
Expand Down Expand Up @@ -83,11 +84,14 @@ class UserStore {

async checkUser(){
try {
console.log("зареган")
const res = await AppAuthRequests.CheckUser();
this.#state.isAuth = true;
this.#state.username = res.username;
router.redirect("/notes")
AppEventMaker.notify(UserStoreEvents.SUCCESSFUL_LOGIN);
} catch (err) {
console.log("не зареган")
router.redirect("/")
}
}
Expand Down

0 comments on commit fae2b7c

Please sign in to comment.