parent
fc1fd30276
commit
7fe6a57cc8
@ -0,0 +1,18 @@ |
||||
packages/rocketchat-livechat/ |
||||
|
||||
public/recorderWorker.js |
||||
lib/ua-parser.min.js |
||||
private/moment-locales/ |
||||
packages/autoupdate/ |
||||
packages/meteor-streams/ |
||||
packages/rocketchat-migrations/ |
||||
packages/rocketchat-katex/client/lib/katex.min.js |
||||
packages/rocketchat-favico/favico.js |
||||
packages/rocketchat-theme/client/minicolors/jquery.minicolors.js |
||||
packages/rocketchat-emojione/generateEmojiIndex.js |
||||
packages/rocketchat-ui/lib/Modernizr.js |
||||
packages/rocketchat-ui/lib/clipboardjs/clipboard.js |
||||
packages/rocketchat-ui/lib/jquery.swipebox.min.js |
||||
packages/rocketchat-ui/lib/particles.js |
||||
packages/rocketchat-ui/lib/recorderjs/recorder.js |
||||
packages/rocketchat-ui/lib/textarea-autogrow.js |
||||
@ -1,67 +1,68 @@ |
||||
|
||||
Meteor.loginWithCas = function(callback) { |
||||
|
||||
var credentialToken = Random.id(); |
||||
var login_url = RocketChat.settings.get("CAS_login_url"); |
||||
var popup_width = RocketChat.settings.get("CAS_popup_width"); |
||||
var popup_height = RocketChat.settings.get("CAS_popup_height"); |
||||
var credentialToken = Random.id(); |
||||
var login_url = RocketChat.settings.get('CAS_login_url'); |
||||
var popup_width = RocketChat.settings.get('CAS_popup_width'); |
||||
var popup_height = RocketChat.settings.get('CAS_popup_height'); |
||||
|
||||
if (!login_url) { |
||||
return; |
||||
} |
||||
if (!login_url) { |
||||
return; |
||||
} |
||||
|
||||
var loginUrl = login_url + "?service=" + Meteor.absoluteUrl('_cas/') + credentialToken; |
||||
var loginUrl = login_url + '?service=' + Meteor.absoluteUrl('_cas/') + credentialToken; |
||||
|
||||
var popup = openCenteredPopup( |
||||
loginUrl, |
||||
popup_width || 800, |
||||
popup_height || 600 |
||||
); |
||||
var popup = openCenteredPopup( |
||||
loginUrl, |
||||
popup_width || 800, |
||||
popup_height || 600 |
||||
); |
||||
|
||||
var checkPopupOpen = setInterval(function() { |
||||
try { |
||||
// Fix for #328 - added a second test criteria (popup.closed === undefined)
|
||||
// to humour this Android quirk:
|
||||
// http://code.google.com/p/android/issues/detail?id=21061
|
||||
var popupClosed = popup.closed || popup.closed === undefined; |
||||
} catch (e) { |
||||
// For some unknown reason, IE9 (and others?) sometimes (when
|
||||
// the popup closes too quickly?) throws "SCRIPT16386: No such
|
||||
// interface supported" when trying to read 'popup.closed'. Try
|
||||
// again in 100ms.
|
||||
return; |
||||
} |
||||
var checkPopupOpen = setInterval(function() { |
||||
var popupClosed; |
||||
try { |
||||
// Fix for #328 - added a second test criteria (popup.closed === undefined)
|
||||
// to humour this Android quirk:
|
||||
// http://code.google.com/p/android/issues/detail?id=21061
|
||||
popupClosed = popup.closed || popup.closed === undefined; |
||||
} catch (e) { |
||||
// For some unknown reason, IE9 (and others?) sometimes (when
|
||||
// the popup closes too quickly?) throws "SCRIPT16386: No such
|
||||
// interface supported" when trying to read 'popup.closed'. Try
|
||||
// again in 100ms.
|
||||
return; |
||||
} |
||||
|
||||
if (popupClosed) { |
||||
clearInterval(checkPopupOpen); |
||||
if (popupClosed) { |
||||
clearInterval(checkPopupOpen); |
||||
|
||||
// check auth on server.
|
||||
Accounts.callLoginMethod({ |
||||
methodArguments: [{ cas: { credentialToken: credentialToken } }], |
||||
userCallback: callback |
||||
}); |
||||
} |
||||
}, 100); |
||||
// check auth on server.
|
||||
Accounts.callLoginMethod({ |
||||
methodArguments: [{ cas: { credentialToken: credentialToken } }], |
||||
userCallback: callback |
||||
}); |
||||
} |
||||
}, 100); |
||||
}; |
||||
|
||||
var openCenteredPopup = function(url, width, height) { |
||||
|
||||
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft; |
||||
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop; |
||||
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth; |
||||
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22); |
||||
// XXX what is the 22?
|
||||
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft; |
||||
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop; |
||||
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth; |
||||
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22); |
||||
// XXX what is the 22?
|
||||
|
||||
// Use `outerWidth - width` and `outerHeight - height` for help in
|
||||
// positioning the popup centered relative to the current window
|
||||
var left = screenX + (outerWidth - width) / 2; |
||||
var top = screenY + (outerHeight - height) / 2; |
||||
var features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes'); |
||||
// Use `outerWidth - width` and `outerHeight - height` for help in
|
||||
// positioning the popup centered relative to the current window
|
||||
var left = screenX + (outerWidth - width) / 2; |
||||
var top = screenY + (outerHeight - height) / 2; |
||||
var features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes'); |
||||
|
||||
var newwindow = window.open(url, 'Login', features); |
||||
if (newwindow.focus) { |
||||
newwindow.focus(); |
||||
} |
||||
var newwindow = window.open(url, 'Login', features); |
||||
if (newwindow.focus) { |
||||
newwindow.focus(); |
||||
} |
||||
|
||||
return newwindow; |
||||
return newwindow; |
||||
}; |
||||
|
||||
@ -1,64 +1,66 @@ |
||||
/* globals logger:true */ |
||||
|
||||
logger = new Logger('CAS', {}); |
||||
|
||||
Meteor.startup(function(){ |
||||
RocketChat.settings.addGroup('CAS', function() { |
||||
this.add("CAS_enabled", false, { type: 'boolean', group: 'CAS', public: true }); |
||||
this.add("CAS_base_url" , '' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add("CAS_login_url" , '' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add("CAS_version" , '1.0' , { type: 'select', values: [{ key: '1.0', i18nLabel: '1.0'}], group: 'CAS' }); |
||||
RocketChat.settings.addGroup('CAS', function() { |
||||
this.add('CAS_enabled', false, { type: 'boolean', group: 'CAS', public: true }); |
||||
this.add('CAS_base_url' , '' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add('CAS_login_url' , '' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add('CAS_version' , '1.0' , { type: 'select', values: [{ key: '1.0', i18nLabel: '1.0'}], group: 'CAS' }); |
||||
|
||||
this.section('CAS Login Layout', function() { |
||||
this.add("CAS_popup_width" , '810' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add("CAS_popup_height" , '610' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add("CAS_button_label_text" , 'CAS' , { type: 'string' , group: 'CAS'}); |
||||
this.add("CAS_button_label_color", '#FFFFFF' , { type: 'color' , group: 'CAS'}); |
||||
this.add("CAS_button_color" , '#13679A' , { type: 'color' , group: 'CAS'}); |
||||
this.add("CAS_autoclose", true , { type: 'boolean' , group: 'CAS'}); |
||||
}); |
||||
}); |
||||
this.section('CAS Login Layout', function() { |
||||
this.add('CAS_popup_width' , '810' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add('CAS_popup_height' , '610' , { type: 'string' , group: 'CAS', public: true }); |
||||
this.add('CAS_button_label_text' , 'CAS' , { type: 'string' , group: 'CAS'}); |
||||
this.add('CAS_button_label_color', '#FFFFFF' , { type: 'color' , group: 'CAS'}); |
||||
this.add('CAS_button_color' , '#13679A' , { type: 'color' , group: 'CAS'}); |
||||
this.add('CAS_autoclose', true , { type: 'boolean' , group: 'CAS'}); |
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
timer = undefined |
||||
|
||||
function updateServices(record) {
|
||||
if( typeof timer != 'undefined' ) { |
||||
Meteor.clearTimeout(timer); |
||||
} |
||||
var timer; |
||||
|
||||
function updateServices(/*record*/) { |
||||
if( typeof timer !== 'undefined' ) { |
||||
Meteor.clearTimeout(timer); |
||||
} |
||||
|
||||
timer = Meteor.setTimeout(function() { |
||||
data = { |
||||
// These will pe passed to 'node-cas' as options
|
||||
enabled: RocketChat.settings.get("CAS_enabled"), |
||||
base_url: RocketChat.settings.get("CAS_base_url"), |
||||
login_url: RocketChat.settings.get("CAS_login_url"), |
||||
// Rocketchat Visuals
|
||||
buttonLabelText: RocketChat.settings.get("CAS_button_label_text"), |
||||
buttonLabelColor: RocketChat.settings.get("CAS_button_label_color"), |
||||
buttonColor: RocketChat.settings.get("CAS_button_color"), |
||||
width: RocketChat.settings.get("CAS_popup_width"), |
||||
height: RocketChat.settings.get("CAS_popup_height"), |
||||
autoclose: RocketChat.settings.get("CAS_autoclose"), |
||||
}; |
||||
timer = Meteor.setTimeout(function() { |
||||
var data = { |
||||
// These will pe passed to 'node-cas' as options
|
||||
enabled: RocketChat.settings.get('CAS_enabled'), |
||||
base_url: RocketChat.settings.get('CAS_base_url'), |
||||
login_url: RocketChat.settings.get('CAS_login_url'), |
||||
// Rocketchat Visuals
|
||||
buttonLabelText: RocketChat.settings.get('CAS_button_label_text'), |
||||
buttonLabelColor: RocketChat.settings.get('CAS_button_label_color'), |
||||
buttonColor: RocketChat.settings.get('CAS_button_color'), |
||||
width: RocketChat.settings.get('CAS_popup_width'), |
||||
height: RocketChat.settings.get('CAS_popup_height'), |
||||
autoclose: RocketChat.settings.get('CAS_autoclose'), |
||||
}; |
||||
|
||||
// Either register or deregister the CAS login service based upon its configuration
|
||||
if( data.enabled ) { |
||||
logger.info("Enabling CAS login service") |
||||
ServiceConfiguration.configurations.upsert({service: 'cas'}, { $set: data }); |
||||
} else { |
||||
logger.info("Disabling CAS login service"); |
||||
ServiceConfiguration.configurations.remove({service: 'cas'}); |
||||
} |
||||
}, 2000); |
||||
}; |
||||
// Either register or deregister the CAS login service based upon its configuration
|
||||
if( data.enabled ) { |
||||
logger.info('Enabling CAS login service'); |
||||
ServiceConfiguration.configurations.upsert({service: 'cas'}, { $set: data }); |
||||
} else { |
||||
logger.info('Disabling CAS login service'); |
||||
ServiceConfiguration.configurations.remove({service: 'cas'}); |
||||
} |
||||
}, 2000); |
||||
} |
||||
|
||||
function check_record (record) { |
||||
if( /^CAS_.+/.test( record._id )){ |
||||
updateServices( record ); |
||||
} |
||||
}; |
||||
if( /^CAS_.+/.test( record._id )){ |
||||
updateServices( record ); |
||||
} |
||||
} |
||||
|
||||
RocketChat.models.Settings.find().observe({ |
||||
added: check_record, |
||||
changed: check_record, |
||||
removed: check_record |
||||
added: check_record, |
||||
changed: check_record, |
||||
removed: check_record |
||||
}); |
||||
|
||||
Loading…
Reference in new issue