MCPcopy
hub / github.com/chartbrew/chartbrew / relog

Function relog

client/src/actions/user.js:293–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

291}
292
293export function relog() {
294 const token = cookie.load("brewToken");
295 return (dispatch) => {
296 if (!token) {
297 if (authenticatePage()) {
298 window.location.pathname = "/login";
299 }
300 return new Promise((resolve, reject) => reject("Token is missing"));
301 }
302
303 const headers = new Headers({
304 "Accept": "application/json",
305 "Content-Type": "application/json",
306 "authorization": `Bearer ${token}`,
307 });
308 const method = "POST";
309 const url = `${API_HOST}/user/relog`;
310
311 return fetch(url, { method, headers })
312 .then((response) => {
313 if (!response.ok) {
314 dispatch(addError(response.status));
315 return new Promise((resolve, reject) => reject("Couldn't relog"));
316 }
317 return response.json();
318 })
319 .then((user) => {
320 dispatch(saveUser(user));
321 redirectToDashboard();
322 return new Promise(resolve => resolve(user));
323 })
324 .catch(() => {
325 if (authenticatePage()) {
326 window.location.pathname = "/login";
327 }
328 return new Promise((resolve, reject) => reject("Can't authenticate the user"));
329 });
330 };
331}
332
333export function getPendingInvites(id) {
334 // get team invites for a specific user

Callers 3

attemptRelogFunction · 0.90
MainFunction · 0.90
UserDashboardFunction · 0.90

Calls 5

addErrorFunction · 0.90
saveUserFunction · 0.85
redirectToDashboardFunction · 0.85
authenticatePageFunction · 0.70
dispatchFunction · 0.50

Tested by

no test coverage detected