Closed developcreativo closed 7 years ago
You just need add $auth
to RoutesRun():
Solo necesitas añadir la variable $auth
a RoutesRun():
export function RoutesRun($state, $transitions, $auth) {
'ngInject';
let requiresAuthCriteria = {
to: ($state) => $state.data && $state.data.auth
};
let redirectToLogin = () => {
'ngInject';
if (!$auth.isAuthenticated()) {
return $state.target('app.login', undefined, {location: false});
}
};
$transitions.onBefore(requiresAuthCriteria, redirectToLogin, {priority:10});
}
Lo siento el codigo al intentar entrar http://localhost:8000/ se queda pensando y no entra al volver al codigo entra normal
unreachable code after return statement[Saber más]final-dba721afbc.js:89286:8
Error: Script terminated by timeout at:
pick@http://localhost:8000/build/js/final-dba721afbc.js:32107:1
defaults@http://localhost:8000/build/js/final-dba721afbc.js:32035:42
State</State.prototype.parameters@http://localhost:8000/build/js/final-dba721afbc.js:37580:17
PathNode@http://localhost:8000/build/js/final-dba721afbc.js:34773:33
PathFactory</PathFactory.buildPath/<@http://localhost:8000/build/js/final-dba721afbc.js:34633:73
PathFactory</PathFactory.buildPath@http://localhost:8000/build/js/final-dba721afbc.js:34633:17
PathFactory</PathFactory.buildToPath@http://localhost:8000/build/js/final-dba721afbc.js:34637:23
Transition@http://localhost:8000/build/js/final-dba721afbc.js:33125:23
TransitionService</TransitionService.prototype.create@http://localhost:8000/build/js/final-dba721afbc.js:36398:17
Transition</Transition.prototype.redirect@http://localhost:8000/build/js/final-dba721afbc.js:33390:30
StateService</StateService.prototype.transitionTo/rejectedTransitionHandler/<@http://localhost:8000/build/js/final-dba721afbc.js:37945:37
processQueue@http://localhost:8000/build/js/final-dba721afbc.js:16383:28
scheduleProcessQueue/<@http://localhost:8000/build/js/final-dba721afbc.js:16399:27
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:8000/build/js/final-dba721afbc.js:17682:16
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:8000/build/js/final-dba721afbc.js:17495:15
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:8000/build/js/final-dba721afbc.js:17790:13
bootstrapApply@http://localhost:8000/build/js/final-dba721afbc.js:1761:9
invoke@http://localhost:8000/build/js/final-dba721afbc.js:4718:16
bootstrap/doBootstrap@http://localhost:8000/build/js/final-dba721afbc.js:1759:5
bootstrap@http://localhost:8000/build/js/final-dba721afbc.js:1779:12
angularInit@http://localhost:8000/build/js/final-dba721afbc.js:1664:5
@http://localhost:8000/build/js/final-dba721afbc.js:31763:5
trigger@http://localhost:8000/build/js/final-dba721afbc.js:3207:7
defaultHandlerWrapper@http://localhost:8000/build/js/final-dba721afbc.js:3497:3
createEventHandler/eventHandler@http://localhost:8000/build/js/final-dba721afbc.js:3485:9
final-dba721afbc.js:32107:1
unreachable code after return statement[Saber más]
replace
let redirectToLogin = ($auth)
by
let redirectToLogin = ()
and
RoutesRun($state, $transitions,$auth)
export function RoutesRun($state, $transitions) { 'ngInject';
}
No escribo ingles pero desde que la instale me da ese error