Skip to content
Closed
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion src/react-components/auth/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import configs from "../../utils/configs";
// TODO: We really shouldn't include these dependencies on every page. A dynamic import would work better.
import jwtDecode from "jwt-decode";
import AuthChannel from "../../utils/auth-channel";
import { connectToReticulum } from "../../utils/phoenix-utils";
import { connectToReticulum, getReticulumFetchUrl } from "../../utils/phoenix-utils";

export const AuthContext = createContext();

Expand Down Expand Up @@ -65,6 +65,12 @@ export function AuthContextProvider({ children, store }) {
const socket = await connectToReticulum();
authChannel.setSocket(socket);
await authChannel.verifyAuthentication(authParams.topic, authParams.token, authParams.payload);
await fetch(getReticulumFetchUrl("/api/v1/accounts/set_cookie"), {
Comment thread
johnshaughnessy marked this conversation as resolved.
Outdated
method: "GET",
Comment thread
johnshaughnessy marked this conversation as resolved.
Outdated
headers: {
authorization: `bearer ${store.state.credentials.token}`
}
});
},
[store]
);
Expand All @@ -74,6 +80,9 @@ export function AuthContextProvider({ children, store }) {
configs.setIsAdmin(false);
store.update({ credentials: { token: null, email: null } });
await store.resetToRandomDefaultAvatar();
await fetch(getReticulumFetchUrl("/api/v1/accounts/expire_cookie"), {
method: "GET"
});
},
[store]
);
Expand Down