Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,20 @@ Enable it in config: `persistent_login/config.inc.php`
$rcmail_config['ifpl_use_auth_tokens'] = true;
```

### OAuth with login redirect
Persistent Login works with OAuth as-is. However, if Roundcube's automatic login redirect setting `oauth_login_redirect` is true, the user will not have the opportunity to select "Keep me logged in" because Roundcube sends the user directly to the OAuth server for authentication (the login screen is not shown at all).

To enable Persistent Login in this case, change Roundcube's `oauth_login_redirect` setting to __false__. In config/config.inc.php:
```php
$config["oauth_login_redirect"] = false;
```

Then, enable Persistent Login's `ifpl_oauth_login_redirect` setting. In `plugins/persistent_login/config.inc.php`
```php
$rcmail_config['ifpl_oauth_login_redirect'] = true;
```

The login screen will be displayed showing only the "Keep me logged in" checkbox and a button to authenticate with the OAuth server.

[roundcube]: http://roundcube.net/
[github-release]: https://github.com/mfreiholz/persistent_login/releases
41 changes: 39 additions & 2 deletions persistent_login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@ $(document).ready(function () {
var html = '';
var parentElementSelector = 'form';
var skin = window.rcmail.env.skin;
var hide_login_form = window.rcmail.env.hide_login_form;

// Insert different HTML for different skins.
if (skin == 'classic' || skin == 'larry') {
parentElementSelector = '#login-form form table tbody';
if (hide_login_form) {
// remove login and password entry rows
$(parentElementSelector).empty();
// remove login button
$('#login-form .formbuttons').remove();
// move ifpl checkbox below oauth button
$('p.oauthlogin').after($('#login-form table').detach());
// left-align checkbox
$('#login-form form table').css({'margin':'0','width':'100%'});
}
html = `
<tr>
<td class="title">` + rcmail.gettext('ifpl_rememberme', 'persistent_login') + `</td>
<td><input type="checkbox" id="_ifpl" name="_ifpl" value="1"></td>
<td width="100%"><input type="checkbox" id="_ifpl" name="_ifpl" value="1"></td>
</tr>
<tr id="ifpl-hint" style="display: none;">
<td></td>
Expand All @@ -35,6 +46,20 @@ $(document).ready(function () {
}
else if (skin == 'elastic') {
parentElementSelector = '#login-form table tbody';
if (hide_login_form) {
// remove login and password entry rows
$(parentElementSelector).empty();
// remove login button
$('#login-form .formbuttons').remove();
// move ifpl checkbox below oauth button
$('p.oauthlogin').after($('#login-form table').detach());
// swap oauthlogin container margins with table's
$('p.oauthlogin').addClass('mt-0 mb-0');
$('#login-form table').css('margin-bottom', '1em');
// make oauth login button a primary color (was secondary)
$('#rcmloginoauth').addClass('btn-primary');
}

html = `
<tr class="form-group row">
<td class="title" style="display: none;">
Expand Down Expand Up @@ -63,6 +88,14 @@ $(document).ready(function () {
`;
}

// oauth links: add _ifpl cookie when clicking link
$('a#rcmloginoauth').prop('onclick', function() {
return function(evt) {
set_ifpl_cookie($('#_ifpl').prop('checked'))
return true;
};
});

// apppend "html" with checkbox to document.
var element = $(parentElementSelector);
if (element && element.length !== 0) {
Expand All @@ -86,4 +119,8 @@ $(document).ready(function () {
});

} // if (window.rcmail)
});

function set_ifpl_cookie(value) {
window.rcmail.set_cookie('_ifpl', value ? "1" : "0");
}
});
Loading