Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #111 from piti-diablotin/master
Browse files Browse the repository at this point in the history
Fix issue with autologin with LDAP and user email
  • Loading branch information
pierre-alain-b authored Jan 23, 2020
2 parents e4fd9d2 + d10ccf4 commit 2a6c2a6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions rainloop/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
$oTemplate = new OCP\Template('rainloop', 'admin-local');
$oTemplate->assign('rainloop-admin-panel-link', OC_RainLoop_Helper::getAppUrl().'?admin');
$oTemplate->assign('rainloop-autologin', \OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin', false));
$oTemplate->assign('rainloop-autologin-with-email', \OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin-with-email', false));
return $oTemplate->fetchPage();
2 changes: 2 additions & 0 deletions rainloop/ajax/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
{
\OC::$server->getConfig()->setAppValue('rainloop', 'rainloop-autologin', isset($_POST['rainloop-autologin']) ?
'1' === $_POST['rainloop-autologin'] : false);
\OC::$server->getConfig()->setAppValue('rainloop', 'rainloop-autologin-with-email', isset($_POST['rainloop-autologin']) ?
'2' === $_POST['rainloop-autologin'] : false);

$bAutologin = \OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin', false);
}
Expand Down
11 changes: 10 additions & 1 deletion rainloop/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,28 @@
$sEncodedPassword = '';

$sUser = OCP\User::getUser();
$sPasswordSalt = '';

if (\OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin', false))
{
$sEmail = $sUser;
$sPasswordSalt = $sUser;
$sEncodedPassword = \OC::$server->getConfig()->getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
}
else if (\OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin-with-email', false))
{
$sEmail = \OC::$server->getConfig()->getUserValue($sUser, 'settings', 'email','');
$sPasswordSalt = $sUser;
$sEncodedPassword = \OC::$server->getConfig()->getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
}
else
{
$sEmail = \OC::$server->getConfig()->getUserValue($sUser, 'rainloop', 'rainloop-email', '');
$sPasswordSalt = $sEmail;
$sEncodedPassword = \OC::$server->getConfig()->getUserValue($sUser, 'rainloop', 'rainloop-password', '');
}

$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sEmail));
$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sPasswordSalt));

$_ENV['___rainloop_owncloud_email'] = $sEmail;
$_ENV['___rainloop_owncloud_password'] = $sDecodedPassword;
Expand Down
2 changes: 1 addition & 1 deletion rainloop/appinfo/app.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
OCP\App::registerAdmin('rainloop', 'admin');
OCP\App::registerPersonal('rainloop', 'personal');

if (\OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin', false))
if (\OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin', false) || \OC::$server->getConfig()->getAppValue('rainloop', 'rainloop-autologin-with-email', false))
{
OCP\Util::connectHook('OC_User', 'post_login', 'OC_RainLoop_Helper', 'login');
OCP\Util::connectHook('OC_User', 'post_setPassword', 'OC_RainLoop_Helper', 'changePassword');
Expand Down
16 changes: 14 additions & 2 deletions rainloop/templates/admin-local.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@
</p>
<br />
<?php endif; ?>
<p>
<p>
<div style="display: flex;">
<input type="radio" id="rainloop-noautologin" name="rainloop-autologin" value="0" <?php if (!$_['rainloop-autologin']&&!$_['rainloop-autologin-with-email']): ?>checked="checked"<?php endif; ?> />
<label style="margin: auto 5px;" for="rainloop-noautologin">
<?php p($l->t('Do not automatically login')); ?>
</label>
</div>
<div style="display: flex;">
<input style="cursor: pointer;" type="checkbox" id="rainloop-autologin" name="rainloop-autologin" value="1" <?php if ($_['rainloop-autologin']): ?>checked="checked"<?php endif; ?> />
<input type="radio" id="rainloop-autologin" name="rainloop-autologin" value="1" <?php if ($_['rainloop-autologin']): ?>checked="checked"<?php endif; ?> />
<label style="margin: auto 5px;" for="rainloop-autologin">
<?php p($l->t('Automatically login with Nextcloud user credentials')); ?>
</label>
</div>
<div style="display: flex;">
<input type="radio" id="rainloop-autologin-with-email" name="rainloop-autologin" value="2" <?php if ($_['rainloop-autologin-with-email']): ?>checked="checked"<?php endif; ?> />
<label style="margin: auto 5px;" for="rainloop-autologin-with-email">
<?php p($l->t('Automatically login with Nextcloud user email credentials')); ?>
</label>
</div>
<br />
<br />
<input type="button" id="rainloop-save-button" name="rainloop-save-button" value="<?php p($l->t('Save')); ?>" />
Expand Down

0 comments on commit 2a6c2a6

Please sign in to comment.