Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cra-rxjs-styled-components/src/constants/url.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const SIGN_IN_BASE_URL = `${API_URL_BASE}/auth/signin`;
export const SIGN_IN_URL = (() => {
const url = new URL(SIGN_IN_BASE_URL);
url.searchParams.set('redirect_url', REDIRECT_URL);
console.log(url.toString());
return url.toString();
})();

Expand Down
9 changes: 7 additions & 2 deletions cra-rxjs-styled-components/src/hooks/auth/use-set-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ export function useSetToken() {
'Content-Type': 'application/json; charset=UTF-8',
}),
credentials: 'include',
selector: (response: Response) => response.json(),
selector: (response: Response) => {
const t = response.json();
console.log(t); // empty object on non-chromium browser (e.g Firefox)
return t;
},
})
.pipe(
tap(({ access_token }) => {
if (!access_token) {
throw new Error(`Error: could not retrieve token`);
}
}),
catchError(() => {
catchError((e) => {
alert(e);
navigate('/signin', { replace: true });
return EMPTY;
})
Expand Down