Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to keep users logged in for longer #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ $wgOAuth2Client['configuration']['scopes'] = 'read_citizen_info'; //Permissions

$wgOAuth2Client['configuration']['service_name'] = 'Citizen Registry'; // the name of your service
$wgOAuth2Client['configuration']['service_login_link_text'] = 'Login with StarMade'; // the text of the login link
$wgOAuth2Client['configuration']['remember_me'] = true; // Whether to keep user logged in for longer, similarly to what would happen if they checked "Keep me logged in" in password-based login. See https://www.mediawiki.org/wiki/Manual:$wgCookieExpiration . Default: false.

```

Expand Down
5 changes: 3 additions & 2 deletions SpecialOAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private function _redirect() {
}

private function _handleCallback(){
global $wgRequest;
global $wgRequest, $wgOAuth2Client;

try {
$storedState = $wgRequest->getSession()->get('oauth2state');
Expand All @@ -117,7 +117,8 @@ private function _handleCallback(){

$resourceOwner = $this->_provider->getResourceOwner($accessToken);
$user = $this->_userHandling( $resourceOwner->toArray() );
$user->setCookies();
$rememberMe = $wgOAuth2Client['configuration']['remember_me'] ?? false;
$user->setCookies(null, null, $rememberMe);

global $wgOut, $wgRequest;
$title = null;
Expand Down