MCPcopy Create free account
hub / github.com/flatlogic/react-material-admin / registerUser

Function registerUser

src/context/UserContext.js:262–297  ·  view source on GitHub ↗
(
  dispatch,
  login,
  password,
  navigate,
)

Source from the content-addressed store, hash-verified

260}
261
262export function registerUser(
263 dispatch,
264 login,
265 password,
266 navigate,
267) {
268 return () => {
269 if (!config.isBackend) {
270 navigate('/login');
271 } else {
272 dispatch({
273 type: 'REGISTER_REQUEST',
274 });
275 if (login.length > 0 && password.length > 0) {
276 axios
277 .post('/auth/signup', { email: login, password })
278 .then(() => {
279 dispatch({
280 type: 'REGISTER_SUCCESS',
281 });
282 showSnackbar({
283 type: 'success',
284 message:
285 "You've been registered successfully. Please check your email for verification link",
286 });
287 navigate('/login');
288 })
289 .catch((err) => {
290 dispatch(authError(err.response.data));
291 });
292 } else {
293 dispatch(authError('Something was wrong. Try again'));
294 }
295 }
296 };
297}
298
299export function verifyEmail(token, navigate) {
300 return () => {

Callers

nothing calls this directly

Calls 2

showSnackbarFunction · 0.90
authErrorFunction · 0.85

Tested by

no test coverage detected