MCPcopy
hub / github.com/chartbrew/chartbrew / verify

Function verify

client/src/actions/user.js:237–263  ·  view source on GitHub ↗
(id, token)

Source from the content-addressed store, hash-verified

235}
236
237export function verify(id, token) {
238 return (dispatch) => {
239 const headers = {
240 "Accept": "application/json",
241 "Authorization": `Bearer ${token}`,
242 };
243 return fetch(`${API_HOST}/user/${id}/verify`, { method: "GET", headers })
244 .then((response) => {
245 if (!response.ok) {
246 dispatch(addError(response.status));
247 throw new Error("Could not verify email.");
248 }
249
250 return response.json();
251 })
252 .then(user => {
253 // save the cookie here
254 cookie.remove("brewToken", { path: "/" });
255 cookie.save("brewToken", user.token, { expires, path: "/" });
256 dispatch(saveUser(user));
257 return new Promise(resolve => resolve(user));
258 })
259 .catch(err => {
260 return new Promise((resolve, reject) => reject(err));
261 });
262 };
263}
264
265export function login(data) {
266 const headers = new Headers({

Callers

nothing calls this directly

Calls 4

addErrorFunction · 0.90
saveUserFunction · 0.85
dispatchFunction · 0.50
removeMethod · 0.45

Tested by

no test coverage detected