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
8 changes: 7 additions & 1 deletion classes/patreon_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static function createOrLogInUserFromPatreon($user_response, $tokens, $re

$login_with_patreon = get_option('patreon-enable-login-with-patreon', true);
$admins_editors_login_with_patreon = get_option('patreon-enable-allow-admins-login-with-patreon', false);
$extend_patreon_cookie_login = get_option('patreon-extend-cookie-login', false);
$danger_user_list = Patreon_Login::getDangerUserList();

// Check if user is logged in to wp:
Expand Down Expand Up @@ -190,7 +191,12 @@ public static function createOrLogInUserFromPatreon($user_response, $tokens, $re
} else {
/* log user into existing wordpress account with matching username */
wp_set_current_user($user->ID, $user->user_login);
wp_set_auth_cookie($user->ID);
/* check if the extended cookie expiration time option is selected */
if (false == $extend_patreon_cookie_login) {
wp_set_auth_cookie( $user->ID );
} else {
wp_set_auth_cookie( $user->ID, true ); /* second parameter set to true means "Remember Me", which sets the auth cookie expiration to 2 weeks */
}
do_action('wp_login', $user->user_login, $user);

// Import Patreon avatar for this user since it is a new user
Expand Down
14 changes: 13 additions & 1 deletion classes/patreon_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function patreon_plugin_register_settings()
register_setting('patreon-options', 'patreon-can-use-api-v2');
register_setting('patreon-options', 'patreon-enable-register-with-patreon');
register_setting('patreon-options', 'patreon-enable-login-with-patreon');
register_setting('patreon-options', 'patreon-enable-allow-admins-login-with-patreon');
register_setting('patreon-options', 'patreon-extend-cookie-login');
register_setting('patreon-options', 'patreon-cookie-login-remember' );
register_setting('patreon-options', 'patreon-enable-redirect-to-page-after-login');
register_setting('patreon-options', 'patreon-enable-redirect-to-page-id');
register_setting('patreon-options', 'patreon-protect-default-image-patreon-level');
Expand Down Expand Up @@ -346,6 +347,17 @@ public function patreon_plugin_setup_page()
</tr>
<?php } ?>

<?php if (get_option('patreon-enable-login-with-patreon', true)) { ?>
<tr valign="top">
<th scope="row">
<strong>Extend Patreon Login cookie expiration</strong>
<div class="patreon-options-info">If on, Patreons will only have to re-sign in once your AUTH_COOKIE_EXPIRATION expires instead of every time they visit your website. Recommended: on</div>
</th>
<td>
<input type="checkbox" name="patreon-extend-cookie-login" value="1"<?php checked(get_option('patreon-enable-allow-admins-login-with-patreon', false)); ?> />
</td>
</tr>
<?php } ?>

<tr valign="top">
<th scope="row">
Expand Down