thingsboard-developers
Details
ui/src/app/api/user.service.js 10(+9 -1)
diff --git a/ui/src/app/api/user.service.js b/ui/src/app/api/user.service.js
index a49c4a0..71c04ce 100644
--- a/ui/src/app/api/user.service.js
+++ b/ui/src/app/api/user.service.js
@@ -27,6 +27,7 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, time
currentUserDetails = null,
lastPublicDashboardId = null,
allowedDashboardIds = [],
+ redirectParams = null,
userTokenAccessEnabled = false,
userLoaded = false;
@@ -56,6 +57,7 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, time
refreshTokenPending: refreshTokenPending,
updateAuthorizationHeader: updateAuthorizationHeader,
setAuthorizationRequestHeader: setAuthorizationRequestHeader,
+ setRedirectParams: setRedirectParams,
gotoDefaultPlace: gotoDefaultPlace,
forceDefaultPlace: forceDefaultPlace,
updateLastPublicDashboardId: updateLastPublicDashboardId,
@@ -541,9 +543,15 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, time
return false;
}
+ function setRedirectParams(params) {
+ redirectParams = params;
+ }
+
function gotoDefaultPlace(params) {
if (currentUser && isAuthenticated()) {
- var place = 'home.links';
+ var place = redirectParams ? redirectParams.toName : 'home.links';
+ params = redirectParams ? redirectParams.params : params;
+ redirectParams = null;
if (currentUser.authority === 'TENANT_ADMIN' || currentUser.authority === 'CUSTOMER_USER') {
if (userHasDefaultDashboard()) {
place = $rootScope.forceFullscreen ? 'dashboard' : 'home.dashboards.dashboard';
ui/src/app/app.run.js 36(+5 -31)
diff --git a/ui/src/app/app.run.js b/ui/src/app/app.run.js
index 4667b09..8064ae5 100644
--- a/ui/src/app/app.run.js
+++ b/ui/src/app/app.run.js
@@ -27,7 +27,6 @@ export default function AppRun($rootScope, $window, $injector, $location, $log,
// ie11 fix
}
- var unauthorizedDialog = null;
var forbiddenDialog = null;
$rootScope.iframeMode = false;
@@ -125,11 +124,11 @@ export default function AppRun($rootScope, $window, $injector, $location, $log,
reloadUserFromPublicId();
} else if (to.module === 'private') {
evt.preventDefault();
- if (to.url === '/home' || to.url === '/') {
- $state.go('login', params);
- } else {
- showUnauthorizedDialog();
- }
+ var redirectParams = {};
+ redirectParams.toName = to.name;
+ redirectParams.params = params;
+ userService.setRedirectParams(redirectParams);
+ $state.go('login', params);
}
}
} else {
@@ -159,31 +158,6 @@ export default function AppRun($rootScope, $window, $injector, $location, $log,
userService.gotoDefaultPlace(params);
}
- function showUnauthorizedDialog() {
- if (unauthorizedDialog === null) {
- $translate(['access.unauthorized-access',
- 'access.unauthorized-access-text',
- 'access.unauthorized',
- 'action.cancel',
- 'action.sign-in']).then(function (translations) {
- if (unauthorizedDialog === null) {
- unauthorizedDialog = $mdDialog.confirm()
- .title(translations['access.unauthorized-access'])
- .textContent(translations['access.unauthorized-access-text'])
- .ariaLabel(translations['access.unauthorized'])
- .cancel(translations['action.cancel'])
- .ok(translations['action.sign-in']);
- $mdDialog.show(unauthorizedDialog).then(function () {
- unauthorizedDialog = null;
- $state.go('login');
- }, function () {
- unauthorizedDialog = null;
- });
- }
- });
- }
- }
-
function showForbiddenDialog() {
if (forbiddenDialog === null) {
$translate(['access.access-forbidden',