Skip to content

Добро пожаловать, или посторонним вход воспрещён (часть 1)#12

Merged
keksobot merged 4 commits into
htmlacademy-react:masterfrom
echenko:module7-task2
May 29, 2026
Merged

Добро пожаловать, или посторонним вход воспрещён (часть 1)#12
keksobot merged 4 commits into
htmlacademy-react:masterfrom
echenko:module7-task2

Conversation

@echenko
Copy link
Copy Markdown

@echenko echenko commented May 26, 2026

@keksobot keksobot changed the title add: login, logout Добро пожаловать, или посторонним вход воспрещён (часть 1) May 26, 2026
@github-actions
Copy link
Copy Markdown

Ваш пулреквест опубликован. Посмотреть можно здесь

github-actions Bot pushed a commit that referenced this pull request May 26, 2026
@github-actions
Copy link
Copy Markdown

Ваш пулреквест опубликован. Посмотреть можно здесь

github-actions Bot pushed a commit that referenced this pull request May 26, 2026
Comment thread src/components/app/app.tsx Outdated

useEffect(() => {
store.dispatch(checkAuthAction());
store.dispatch(fetchOffersAction());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему ты сюда перенес запрос офферов?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправил

Comment thread src/store/api-actions.ts Outdated
async (_arg, {dispatch, extra: api}) => {
try {
await api.get(APIRoute.Login);
dispatch(addUserEmail(getUserEmail()));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут после авторизации email приходит в самом запросе, его не надо брать из localStorage

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вроде исправил)

Comment thread src/store/api-actions.ts
dispatch(addUserEmail(getUserEmail()));
dispatch(requireAuthorization(AuthorizationStatus.Auth));
} catch {
dispatch(requireAuthorization(AuthorizationStatus.NoAuth));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот тут, если авторизация не успешная, лучше дополнительно почистить и email и token

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправил


export type UserEmail = string;

export const getUserEmail = (): UserEmail => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email хранится и в localStorage и в redux store, это два источника истины, нужно оставить что-то одно

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

оставил локал

Comment thread src/store/action.ts Outdated

export const requireAuthorization = createAction<AuthorizationStatus>('user/requireAuthorization');

export const addUserEmail = createAction<string>('user/saveUserEmail');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Экшены лучше называть по названиям эндпоинтов, как здесь - saveUserEmail

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалил

Comment thread src/components/app/app.tsx Outdated

useEffect(() => {
store.dispatch(checkAuthAction());
store.dispatch(fetchOffersAction());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кстати, у тебя есть useAppDispatch, используй его, вместо store.dispatch

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправил

@github-actions
Copy link
Copy Markdown

Ваш пулреквест опубликован. Посмотреть можно здесь

github-actions Bot pushed a commit that referenced this pull request May 28, 2026
@github-actions
Copy link
Copy Markdown

Ваш пулреквест опубликован. Посмотреть можно здесь

github-actions Bot pushed a commit that referenced this pull request May 28, 2026
@keksobot keksobot merged commit 702aa8a into htmlacademy-react:master May 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants