|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+session_start();
|
|
|
//demo https://aroz.alanyeung.co/oauth.php
|
|
|
//please go to https://github.com/settings/applications/ to get the client_id and client_secret, pleae remind that the redirect_uri must be same as github.com
|
|
|
$baselink = "https://github.com/login/oauth"; //do not change it
|
|
@@ -43,11 +44,15 @@ if(isset($_GET["code"])){
|
|
|
));
|
|
|
$result = curl_exec($chs);
|
|
|
curl_close($chs);
|
|
|
+ $userinfo = [];
|
|
|
$userinfo = json_decode($result,true);
|
|
|
- //print_r($userinfo);
|
|
|
- session_start();
|
|
|
- $_SESSION["login"] = $userinfo["login"];
|
|
|
- setcookie("username",$userinfo["login"],time()+ 172800 );
|
|
|
- setcookie("password","OAuthGithub",time()+ 172800 );
|
|
|
- echo '<script>localStorage.ArOZusername = "'.$userinfo["login"].'";window.location = "./index.php"</script>';
|
|
|
+ if($userinfo == []){
|
|
|
+ echo "Error!";
|
|
|
+ }else{
|
|
|
+ $_SESSION["method"] = "Github";
|
|
|
+ $_SESSION["login"] = $userinfo["login"];
|
|
|
+ setcookie("username",$userinfo["login"],time()+ 172800 );
|
|
|
+ setcookie("password","OAuthGithub",time()+ 172800 );
|
|
|
+ echo '<script>localStorage.ArOZusername = "'.$userinfo["login"].'";window.location = "./index.php"</script>';
|
|
|
+ }
|
|
|
}
|