mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Adjustments to Socket Service for session-limit PR
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
import ReconnectingWebSocket from 'reconnectingwebsocket';
|
import ReconnectingWebSocket from 'reconnectingwebsocket';
|
||||||
export default
|
export default
|
||||||
['$rootScope', '$location', '$log','$state', '$q', 'i18n',
|
['$rootScope', '$location', '$log','$state', '$q', 'i18n', 'GetBasePath', 'Rest',
|
||||||
function ($rootScope, $location, $log, $state, $q, i18n) {
|
function ($rootScope, $location, $log, $state, $q, i18n, GetBasePath, Rest) {
|
||||||
var needsResubscribing = false,
|
var needsResubscribing = false,
|
||||||
socketPromise = $q.defer(),
|
socketPromise = $q.defer(),
|
||||||
needsRefreshAfterBlur;
|
needsRefreshAfterBlur;
|
||||||
@@ -130,16 +130,16 @@ export default
|
|||||||
else if(data.group_name==="inventory_update_events"){
|
else if(data.group_name==="inventory_update_events"){
|
||||||
str = `ws-${data.group_name}-${data.inventory_update}`;
|
str = `ws-${data.group_name}-${data.inventory_update}`;
|
||||||
}
|
}
|
||||||
else if(data.group_name==="control" && data.reason=="limit_reached"){
|
else if(data.group_name === "control" && data.reason === "limit_reached"){
|
||||||
// If we got a `limit_reached_<user_pk>` message, determine
|
// If we got a `limit_reached_<user_pk>` message, determine
|
||||||
// if the current session is still valid (it may have been
|
// if the current session is still valid (it may have been
|
||||||
// invalidated)
|
// invalidated)
|
||||||
// If so, log the user out and show a meaningful error
|
// If so, log the user out and show a meaningful error
|
||||||
$log.debug(data.reason);
|
$log.debug(data.reason);
|
||||||
self.$.ajax({
|
let url = GetBasePath('me');
|
||||||
url: '/api/v2/me/'
|
Rest.get(url)
|
||||||
}).error(function(resp, status) {
|
.catch(function(resp) {
|
||||||
if (resp.status == 401) {
|
if (resp.status === 401) {
|
||||||
$rootScope.sessionTimer.expireSession('session_limit');
|
$rootScope.sessionTimer.expireSession('session_limit');
|
||||||
$state.go('signOut');
|
$state.go('signOut');
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ export default
|
|||||||
// listen for specific messages. A subscription object could
|
// listen for specific messages. A subscription object could
|
||||||
// look like {"groups":{"jobs": ["status_changed", "summary"]}.
|
// look like {"groups":{"jobs": ["status_changed", "summary"]}.
|
||||||
// This is used by all socket-enabled $states
|
// This is used by all socket-enabled $states
|
||||||
state.data.socket.groups['control'] = ['limit_reached_' + $rootScope.current_user.id];
|
state.data.socket.groups.control = ['limit_reached_' + $rootScope.current_user.id];
|
||||||
this.emit(JSON.stringify(state.data.socket));
|
this.emit(JSON.stringify(state.data.socket));
|
||||||
this.setLast(state);
|
this.setLast(state);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user