mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Make sure session is loaded before route is rendered
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<base href="/">
|
||||
<title>Redash</title>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<base href="/">
|
||||
<title>Redash</title>
|
||||
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="./assets/images/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="./assets/images/favicon-96x96.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="./assets/images/favicon-16x16.png">
|
||||
</head>
|
||||
<body ng-app="app">
|
||||
<section>
|
||||
<div ng-view></div>
|
||||
</section>
|
||||
</body>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="./assets/images/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="./assets/images/favicon-96x96.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="./assets/images/favicon-16x16.png">
|
||||
</head>
|
||||
|
||||
<body ng-app="app">
|
||||
<section>
|
||||
<div ng-view></div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -116,10 +116,16 @@ ngModule.config(($routeProvider,
|
||||
});
|
||||
});
|
||||
|
||||
ngModule.run(($location, $rootScope, Auth) => {
|
||||
ngModule.run(($location, $rootScope, $route, Auth) => {
|
||||
$rootScope.$on('$routeChangeStart', (event, to) => {
|
||||
if (!Auth.isAuthenticated()) {
|
||||
console.log('need to login', to);
|
||||
event.preventDefault();
|
||||
// maybe we only miss the session? try to load session
|
||||
Auth.loadSession().then(() => {
|
||||
$route.reload();
|
||||
}).catch(() => {
|
||||
Auth.login();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user