Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an error if login, signUp and forgotPassword screens are not allowed #850

Merged
merged 1 commit into from
Feb 21, 2017
Merged
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
33 changes: 23 additions & 10 deletions src/engine/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ const setPrefill = m => {
return m;
}

function createErrorScreen(m, stopError) {
setTimeout(() => {
swap(updateEntity, "lock", l.id(m), l.stop, stopError);
}, 0);

return new ErrorScreen();
}

class Classic {

static SCREENS = {
Expand Down Expand Up @@ -171,17 +179,22 @@ class Classic {
}
}

const Screen = Classic.SCREENS[getScreen(m)];
if (Screen) return new Screen();

setTimeout(() => {
const stopError = new Error("Internal error");
stopError.code = "internal_error";
stopError.description = `Couldn't find a screen "${getScreen(m)}"`;
swap(updateEntity, "lock", l.id(m), l.stop, stopError);
}, 0);
if (!hasScreen(m, 'login') && !hasScreen(m, 'signUp') && !hasScreen(m, 'forgotPassword')) {
const errorMessage = "No available Screen. You have to allow at least one of those screens: `login`, `signUp`or `forgotPassword`.";
const noAvailableScreenError = new Error(errorMessage);
noAvailableScreenError.code = "internal_error";
noAvailableScreenError.description = errorMessage;
return createErrorScreen(m, noAvailableScreenError);
}

return new ErrorScreen();
const Screen = Classic.SCREENS[getScreen(m)];
if (Screen) {
return new Screen();
}
const noScreenError = new Error("Internal error");
noScreenError.code = "internal_error";
noScreenError.description = `Couldn't find a screen "${getScreen(m)}"`;
return createErrorScreen(m, noScreenError);
}

}
Expand Down