Skip to content

Commit

Permalink
New feature: Option to prefill credentials in demo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed May 8, 2014
1 parent 5316347 commit f2aadfe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions application/config/config-defaults.php
Expand Up @@ -236,6 +236,15 @@

$config['demoMode'] = false;

/**
* Prefill the login mask using the parameters 'defaultuser' and 'default pass'. This works only if demo mode (demoMode) is activated.
* Also a notice will be shown that the user knows that he can just login by using the Login button.
*
* @var $config['demoModePrefill'] boolan If set to true prefill the login mask
*/
$config['demoModePrefill'] = false;


/**
* column_style
* Because columns are tricky things, in terms of balancing visual
Expand Down
15 changes: 12 additions & 3 deletions application/core/plugins/Authdb/Authdb.php
Expand Up @@ -46,7 +46,7 @@ public function beforeLogin()
// We have a one time password, skip the login form
$this->setOnePass($request->getParam('onepass'));
$this->setUsername($request->getParam('user'));
$this->setAuthPlugin(); // This plugin will handle authentication ans skips the login form
$this->setAuthPlugin(); // This plugin will handle authentication and skips the login form
}
}

Expand All @@ -62,9 +62,18 @@ protected function getOnePass()

public function newLoginForm()
{

$sUserName='';
$sPassword='';
if (Yii::app()->getConfig("demoMode") === true && Yii::app()->getConfig("demoModePrefill") === true)
{
$sUserName=Yii::app()->getConfig("defaultuser");
$sPassword=Yii::app()->getConfig("defaultpass");
}

$this->getEvent()->getContent($this)
->addContent(CHtml::tag('li', array(), "<label for='user'>" . gT("Username") . "</label><input name='user' id='user' type='text' size='40' maxlength='40' value='' />"))
->addContent(CHtml::tag('li', array(), "<label for='password'>" . gT("Password") . "</label><input name='password' id='password' type='password' size='40' maxlength='40' value='' />"));
->addContent(CHtml::tag('li', array(), "<label for='user'>" . gT("Username") . "</label>".CHtml::textField('user',$sUserName,array('size'=>40,'maxlength'=>40))))
->addContent(CHtml::tag('li', array(), "<label for='password'>" . gT("Password") . "</label>".CHtml::passwordField('password',$sPassword,array('size'=>40,'maxlength'=>40))));
}

public function afterLoginFormSubmit()
Expand Down
5 changes: 5 additions & 0 deletions application/views/admin/authentication/login.php
Expand Up @@ -62,6 +62,11 @@
echo CHtml::closeTag('li');
?>
</ul>
<?php if (Yii::app()->getConfig("demoMode") === true && Yii::app()->getConfig("demoModePrefill") === true)
{ ?>
<p><?php $clang->eT("Demo mode: Login credentials are prefilled - just click the Login button."); ?></p>
<?php } ?>

<p><input type='hidden' name='action' value='login' />
<input class='action' type='submit' name='login_submit' value='<?php $clang->eT("Login"); ?>' /><br />
<br/>
Expand Down

3 comments on commit f2aadfe

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, great idea, but can be in plugin , no ? Because ther are not a lot of user using demo mode.

(And then : to activate : just activate the plugin, and you can set the plugin 'not deactivable' via the web GUI: only via FTP).

@SamMousa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the whole demo mode should become a plugin in the future.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can already have :

  • Deactivate send mail
  • Admin login

Please sign in to comment.