-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.x' into 2.x
# Conflicts: # README.md
- Loading branch information
Showing
49 changed files
with
2,549 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
if ($object->xpdo) { | ||
switch ($options[xPDOTransport::PACKAGE_ACTION]) { | ||
case xPDOTransport::ACTION_INSTALL: | ||
case xPDOTransport::ACTION_UPGRADE: | ||
/** @var modX $modx */ | ||
$modx =& $object->xpdo; | ||
|
||
$permissions = array('twilio_manage_auth'); | ||
|
||
foreach ($permissions as $permission) { | ||
$accessPermission = $modx->getObject('modAccessPermission', array( | ||
'template' => 1, | ||
'name' => $permission | ||
)); | ||
|
||
if (!$accessPermission) { | ||
$accessPermission = $modx->newObject('modAccessPermission'); | ||
$accessPermission->set('template', 1); | ||
$accessPermission->set('name', $permission); | ||
$accessPermission->set('value', 1); | ||
$accessPermission->save(); | ||
} | ||
} | ||
|
||
break; | ||
} | ||
} | ||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php'; | ||
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'; | ||
require_once MODX_CONNECTORS_PATH . 'index.php'; | ||
|
||
$corePath = $modx->getOption('twilio.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/twilio/'); | ||
$twilio = $modx->getService( | ||
'twilio', | ||
'Twilio', | ||
$corePath . 'model/twilio/', | ||
array( | ||
'core_path' => $corePath | ||
) | ||
); | ||
|
||
/* handle request */ | ||
$modx->request->handleRequest( | ||
array( | ||
'processors_path' => $twilio->getOption('processorsPath', null, $corePath . 'processors/'), | ||
'location' => '', | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#modx-leftbar, .x-layout-cmini-west { | ||
display: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Ext.onReady(function() { | ||
var div = document.getElementById('modx-panel-profile-update'); | ||
div.innerHTML = div.innerHTML + '<div class="x-form-item x-tab-item x-form-element">' | ||
+ '<label for="qrcode" style="width:auto;" class="x-form-item-label">'+ | ||
twilio.qrText | ||
+':\n\</label></div>' | ||
+ '<div id="qrcode"><img id="qrimg" src=""></div>'; | ||
MODx.Ajax.request({ | ||
url: twilio.config.connector_url, | ||
params:{action:'totp/qr', user: twilio.config.user.user}, | ||
listeners:{ | ||
'success':{fn:function(r){ document.getElementById("qrimg").src = r.object.qr;},scope:this }, | ||
'failure':{fn:function(){ },scope:this}}}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
twilio.page.Totp = function(config) { | ||
config = config || {}; | ||
Ext.applyIf(config,{ | ||
components: [{ | ||
xtype: 'twilio-panel-totp', | ||
renderTo: 'twilio-panel-totp-div' | ||
}] | ||
}); | ||
twilio.page.Totp.superclass.constructor.call(this,config); | ||
} | ||
Ext.extend(twilio.page.Totp,MODx.Component); | ||
Ext.reg('twilio-page-totp',twilio.page.Totp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
twilio.page.Users = function(config) { | ||
config = config || {}; | ||
Ext.applyIf(config,{ | ||
components: [{ | ||
xtype: 'twilio-panel-users', | ||
renderTo: 'twilio-panel-users-div' | ||
}] | ||
}); | ||
twilio.page.Users.superclass.constructor.call(this,config); | ||
} | ||
Ext.extend(twilio.page.Users,MODx.Component); | ||
Ext.reg('twilio-page-users',twilio.page.Users); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var Twilio = function (config) { | ||
config = config || {}; | ||
Twilio.superclass.constructor.call(this,config); | ||
}; | ||
Ext.extend(Twilio, Ext.Component, { | ||
page:{},window:{},grid:{},tree:{},panel:{},combo:{},config: {} | ||
}); | ||
Ext.reg('twilio',Twilio); | ||
twilio = new Twilio(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
twilio.panel.Totp = function (config) { | ||
var twilioDeviceId = localStorage.getItem('twilio_device_id'); | ||
var generateId = function (length) { | ||
var result = ''; | ||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
var charactersLength = characters.length; | ||
for ( var i = 0; i < length; i++ ) { | ||
result += characters.charAt(Math.floor(Math.random() * | ||
charactersLength)); | ||
} | ||
return result; | ||
} | ||
if (twilioDeviceId == null) { | ||
twilioDeviceId = generateId(16); | ||
localStorage.setItem('twilio_device_id', twilioDeviceId); | ||
} else { | ||
if (MODx.request.device_id == null) { | ||
MODx.loadPage('totp', 'namespace=twilio&device_id=' + twilioDeviceId); | ||
} | ||
} | ||
config = config || {}; | ||
Ext.applyIf(config,{ | ||
border: false | ||
,baseCls: 'modx-formpanel' | ||
,cls: 'container' | ||
,items: [{ | ||
html: '<h2>' + _('twilio.2fa') + '</h2>' | ||
,border: false | ||
,cls: 'modx-page-header' | ||
}, { | ||
xtype: 'modx-formpanel', | ||
layout: 'form', | ||
id: 'twilio-form-totp', | ||
cls: 'form-with-labels main-wrapper', | ||
anchor: '100%', | ||
border: false, | ||
autoHeight: true, | ||
style: 'padding-top: 15px', | ||
url: twilio.config.connector_url, | ||
waitMsg: _('twilio.verifying'), | ||
success: function (form, action) { | ||
console.log(action.result); | ||
window.location = MODx.config.manager_url; | ||
}, | ||
failure: function (form, action) { | ||
Ext.Msg.alert(_('error'), action.result.message); | ||
}, | ||
items: [{ | ||
html: '<p>' + (twilio.config.user.status === 'verified' ? _('twilio.2fa.challenge_msg') : _('twilio.2fa.verify_msg')) + '</p>' | ||
},{ | ||
name: 'user', | ||
xtype: 'hidden', | ||
value: twilio.config.user.user | ||
},{ | ||
name: 'action', | ||
xtype: 'hidden', | ||
value: twilio.config.user.status === 'verified' ? 'totp/challenge' : 'totp/verify' | ||
},{ | ||
name: 'devicecode', | ||
xtype: 'hidden', | ||
value: twilioDeviceId | ||
},{ | ||
name: 'code', | ||
fieldLabel: _('twilio.2fa.code'), | ||
xtype: 'textfield', | ||
anchor: '100%', | ||
},{ | ||
name: 'rememberdevice', | ||
boxLabel: _('twilio.2fa.rememberdevice'), | ||
xtype: 'checkbox', | ||
anchor: '100%', | ||
}], | ||
buttons: [ | ||
{ | ||
text: _('twilio.submit'), | ||
handler: function () { | ||
var form = Ext.getCmp('twilio-form-totp'); | ||
if (form.isDirty()) { | ||
form.submit(); | ||
} | ||
} | ||
} | ||
] | ||
}] | ||
}); | ||
twilio.panel.Totp.superclass.constructor.call(this,config); | ||
} | ||
Ext.extend(twilio.panel.Totp, MODx.Panel); | ||
Ext.reg('twilio-panel-totp',twilio.panel.Totp); |
Oops, something went wrong.