Skip to content

Commit

Permalink
Merge branch 'answers_html' of https://github.com/LimeSurvey/LimeSurvey
Browse files Browse the repository at this point in the history
… into answers_html
  • Loading branch information
Shnoulle committed Oct 24, 2016
2 parents e0bec56 + 6ffb10e commit 6198cd5
Show file tree
Hide file tree
Showing 63 changed files with 2,662 additions and 1,830 deletions.
4 changes: 2 additions & 2 deletions application/config/version.php
Expand Up @@ -12,11 +12,11 @@
*150413
*/

$config['versionnumber'] = '2.54.3 (answers_html)';
$config['versionnumber'] = '2.55 (answers_html)';
$config['dbversionnumber'] = 261;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '36';
$config['assetsversionnumber'] = '37';
return $config;

?>
36 changes: 28 additions & 8 deletions application/controllers/admin/authentication.php
Expand Up @@ -85,6 +85,23 @@ public static function prepareLogin()
{
$aData = array();

// Plugins, include core plugins, can't be activated by default.
// So after a fresh installation, core plugins are not activated
// They need to be manually loaded.
if (!class_exists('Authdb', false)) {
$plugin = Plugin::model()->findByAttributes(array('name'=>'Authdb'));
if (!$plugin) {
$plugin = new Plugin();
$plugin->name = 'Authdb';
$plugin->active = 1;
$plugin->save();
App()->getPluginManager()->loadPlugin('Authdb', $plugin->id);
} else {
$plugin->active = 1;
$plugin->save();
}
}

// In Authdb, the plugin event "beforeLogin" checks if the url param "onepass" is set
// if yes, it will call AuthPluginBase::setAuthPlugin to set to true the plugin private parameter "_stop", so the form will not be displayed
// @see: application/core/plugins/Authdb/Authdb.php: function beforeLogin()
Expand Down Expand Up @@ -125,9 +142,7 @@ public static function prepareLogin()
App()->getPluginManager()->dispatchEvent($newLoginForm); // inject the HTML of the form inside the private varibale "_content" of the plugin
$aData['summary'] = self::getSummary('logout');
$aData['pluginContent'] = $newLoginForm->getAllContent(); // Retreives the private varibale "_content" , and parse it to $aData['pluginContent'], which will be rendered in application/views/admin/authentication/login.php
}
else
{
}else{
// The form has been submited, or the plugin has been stoped (so normally, the value of login/password are available)

// Handle getting the post and populating the identity there
Expand All @@ -143,10 +158,17 @@ public static function prepareLogin()
$identity = $event->get('identity');

// Now authenticate
if ($identity->authenticate())
{
// This call LSUserIdentity::authenticate() (application/core/LSUserIdentity.php))
// which will call the plugin function newUserSession() (eg: Authdb::newUserSession() )
// TODO: for sake of clarity, the plugin function should be renamed to authenticate().
if ($identity->authenticate()){
FailedLoginAttempt::model()->deleteAttempts();
App()->user->setState('plugin', $authMethod);

// This call to AdminController::_GetSessionUserRights() ;
// NB 1:calling another controller method from a controller method is a bad pratice
// NB 2: this function only check if logged in user is super admin to set in session USER_RIGHT_INITIALSUPERADMIN
// TODO: move this function to the user object
Yii::app()->getController()->_GetSessionUserRights(Yii::app()->session['loginID']);
Yii::app()->session['just_logged_in'] = true;
Yii::app()->session['loginsummary'] = self::getSummary();
Expand All @@ -155,9 +177,7 @@ public static function prepareLogin()
App()->getPluginManager()->dispatchEvent($event);

return array('success');
}
else
{
}else{
// Failed
$event = new PluginEvent('afterFailedLoginAttempt');
$event->set('identity', $identity);
Expand Down

0 comments on commit 6198cd5

Please sign in to comment.