check if user was ejected
This commit is contained in:
parent
d0f6e4f3a2
commit
90bfea5d77
@ -5,7 +5,6 @@ import { log } from '/imports/ui/services/api';
|
||||
const STATUS_CONNECTING = 'connecting';
|
||||
|
||||
export function joinRouteHandler(nextState, replace, callback) {
|
||||
console.log('joinRouteHandler - imports-startup-client-auth.js');
|
||||
const { sessionToken } = nextState.location.query;
|
||||
|
||||
if (!nextState || !sessionToken) {
|
||||
@ -19,7 +18,9 @@ export function joinRouteHandler(nextState, replace, callback) {
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then((data) => {
|
||||
const { meetingID, internalUserID, authToken, logoutUrl } = data.response;
|
||||
const {
|
||||
meetingID, internalUserID, authToken, logoutUrl,
|
||||
} = data.response;
|
||||
|
||||
Auth.set(meetingID, internalUserID, authToken, logoutUrl, sessionToken);
|
||||
replace({ pathname: '/' });
|
||||
@ -28,7 +29,6 @@ export function joinRouteHandler(nextState, replace, callback) {
|
||||
}
|
||||
|
||||
export function logoutRouteHandler(nextState, replace) {
|
||||
console.log('logoutRouteHandler - imports-startup-client-auth.js');
|
||||
Auth.logout()
|
||||
.then((logoutURL = window.location.origin) => {
|
||||
const protocolPattern = /^((http|https):\/\/)/;
|
||||
@ -46,7 +46,6 @@ export function logoutRouteHandler(nextState, replace) {
|
||||
* @param {String} lastStatus
|
||||
*/
|
||||
export function shouldAuthenticate(status, lastStatus) {
|
||||
console.log('shouldAuthenticate - imports-startup-client-auth.js');
|
||||
return lastStatus != null && lastStatus === STATUS_CONNECTING && status.connected;
|
||||
}
|
||||
|
||||
@ -56,12 +55,10 @@ export function shouldAuthenticate(status, lastStatus) {
|
||||
* @param {string} lastStatus
|
||||
*/
|
||||
export function updateStatus(status, lastStatus) {
|
||||
console.log('updateStatus - imports-startup-client-auth.js');
|
||||
return status.retryCount > 0 && lastStatus !== STATUS_CONNECTING ? status.status : lastStatus;
|
||||
}
|
||||
|
||||
function _addReconnectObservable() {
|
||||
console.log('_addReconnectObservable - imports-startup-client-auth.js');
|
||||
let lastStatus = null;
|
||||
|
||||
Tracker.autorun(() => {
|
||||
@ -75,7 +72,6 @@ function _addReconnectObservable() {
|
||||
}
|
||||
|
||||
export function authenticatedRouteHandler(nextState, replace, callback) {
|
||||
console.log('authenticatedRouteHandler - imports-startup-client-auth.js');
|
||||
const credentialsSnapshot = {
|
||||
meetingId: Auth.meetingID,
|
||||
requesterUserId: Auth.userID,
|
||||
|
@ -51,9 +51,6 @@ class Base extends Component {
|
||||
}
|
||||
|
||||
renderByState() {
|
||||
console.log('renderByState - imports-startup-client-base.jsx');
|
||||
console.log(this.props.params);
|
||||
|
||||
const { updateLoadingState, updateErrorState } = this;
|
||||
const stateControls = { updateLoadingState, updateErrorState };
|
||||
|
||||
@ -76,7 +73,6 @@ class Base extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log('render - imports-startup-client-base.jsx');
|
||||
const { updateLoadingState, updateErrorState } = this;
|
||||
const { locale } = this.props;
|
||||
const stateControls = { updateLoadingState, updateErrorState };
|
||||
@ -100,10 +96,6 @@ const SUBSCRIPTIONS_NAME = [
|
||||
const BaseContainer = withRouter(withTracker(({ params, router }) => {
|
||||
if (params.errorCode) return params;
|
||||
|
||||
console.log('BaseContainer - imports-startup-client-base.jsx');
|
||||
console.log(params);
|
||||
console.log(Auth);
|
||||
|
||||
if (!Auth.loggedIn) {
|
||||
return router.push('/logout');
|
||||
}
|
||||
@ -113,7 +105,6 @@ const BaseContainer = withRouter(withTracker(({ params, router }) => {
|
||||
|
||||
const subscriptionErrorHandler = {
|
||||
onError: (error) => {
|
||||
console.log('onError - imports-startup-client-base.jsx');
|
||||
console.error(error);
|
||||
return router.push('/logout');
|
||||
},
|
||||
|
@ -35,6 +35,12 @@ const propTypes = {
|
||||
};
|
||||
|
||||
class MeetingEnded extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { router } = this.props;
|
||||
|
||||
setTimeout(() => { router.push('/logout'); }, 3000);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { intl, router, code } = this.props;
|
||||
|
||||
|
@ -10,7 +10,6 @@ const CONNECTION_TIMEOUT = Meteor.settings.public.app.connectionTimeout;
|
||||
|
||||
class Auth {
|
||||
constructor() {
|
||||
console.log('constructor - imports-ui-services-auth-index.js');
|
||||
this._meetingID = Storage.getItem('meetingID');
|
||||
this._userID = Storage.getItem('userID');
|
||||
this._authToken = Storage.getItem('authToken');
|
||||
@ -88,7 +87,6 @@ class Auth {
|
||||
}
|
||||
|
||||
set(meetingId, requesterUserId, requesterToken, logoutURL, sessionToken) {
|
||||
console.log('set - imports-ui-services-auth-index.js');
|
||||
this.meetingID = meetingId;
|
||||
this.userID = requesterUserId;
|
||||
this.token = requesterToken;
|
||||
@ -97,7 +95,6 @@ class Auth {
|
||||
}
|
||||
|
||||
clearCredentials(...args) {
|
||||
console.log('clearCredentials - imports-ui-services-auth-index.js');
|
||||
this.meetingID = null;
|
||||
this.userID = null;
|
||||
this.token = null;
|
||||
@ -109,7 +106,6 @@ class Auth {
|
||||
}
|
||||
|
||||
logout() {
|
||||
console.log('logout - imports-ui-services-auth-index.js');
|
||||
if (!this.loggedIn) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -120,8 +116,6 @@ class Auth {
|
||||
}
|
||||
|
||||
authenticate(force) {
|
||||
console.log('authenticate - imports-ui-services-auth-index.js');
|
||||
|
||||
if (this.loggedIn && !force) return Promise.resolve();
|
||||
|
||||
if (!(this.meetingID && this.userID && this.token)) {
|
||||
@ -135,8 +129,6 @@ class Auth {
|
||||
}
|
||||
|
||||
validateAuthToken() {
|
||||
console.log('validateAuthtToken - imports-ui-services-auth-index.js');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let computation = null;
|
||||
|
||||
@ -149,8 +141,6 @@ class Auth {
|
||||
}, CONNECTION_TIMEOUT);
|
||||
|
||||
Tracker.autorun((c) => {
|
||||
|
||||
console.log('tracker - imports-ui-services-auth-index.js');
|
||||
computation = c;
|
||||
const subscription = Meteor.subscribe('current-user', this.credentials);
|
||||
|
||||
@ -162,11 +152,18 @@ class Auth {
|
||||
// Skip in case the user is not in the collection yet or is a dummy user
|
||||
if (!User || !('intId' in User)) return;
|
||||
|
||||
console.log('state of User');
|
||||
console.log(User);
|
||||
|
||||
if (User.validated === true) {
|
||||
console.log('User.validated === true');
|
||||
if (User.ejected) {
|
||||
computation.stop();
|
||||
clearTimeout(validationTimeout);
|
||||
this.loggedIn = false;
|
||||
|
||||
return reject({
|
||||
error: 401,
|
||||
description: 'User has been ejected.',
|
||||
});
|
||||
}
|
||||
|
||||
computation.stop();
|
||||
clearTimeout(validationTimeout);
|
||||
this.loggedIn = true;
|
||||
|
Loading…
Reference in New Issue
Block a user