Skip to content

Commit

Permalink
Merge pull request #850 from auth0/fix/fail-when-login-and-signup-are…
Browse files Browse the repository at this point in the history
…-disabled

Throw an error if login, signUp and forgotPassword screens are not allowed
  • Loading branch information
hzalaz authored Feb 21, 2017
2 parents feb4fe2 + 267d568 commit ab04969
Showing 1 changed file with 23 additions and 10 deletions.
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

0 comments on commit ab04969

Please sign in to comment.