forked from fsr/padlist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32d483a
Showing
7 changed files
with
905 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor/ | ||
providerConfig.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
#error_reporting(E_ALL); | ||
#ini_set('display_errors', 1); | ||
|
||
|
||
session_start(); | ||
|
||
$provider = require 'providerConfig.php'; | ||
|
||
try { | ||
if (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { | ||
unset($_SESSION['oauth2state']); | ||
throw new Exception('Invalid state'); | ||
} | ||
|
||
$token = $provider->getAccessToken('authorization_code', [ | ||
'code' => $_GET['code'] | ||
]); | ||
|
||
$resourceOwner = $provider->getResourceOwner($token); | ||
$userData = $resourceOwner->toArray(); | ||
|
||
|
||
// Save user data and token in session or database here | ||
$_SESSION['user'] = $userData["name"]; | ||
$_SESSION['token'] = $token->getToken(); | ||
|
||
// Redirect to index.php | ||
header('Location: index.php'); | ||
exit(); | ||
|
||
} catch (Exception $e) { | ||
// Log the error message and display a generic error message to the user | ||
error_log($e->getMessage()); | ||
echo '<p>An error occurred during the login process. Please try again.</p>'; | ||
echo '<p><a href="index.php">Try again</a></p>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"require": { | ||
"league/oauth2-client": "^2.7" | ||
} | ||
} |
Oops, something went wrong.