Example #1
0
     if ($state !== \Session::get('state')) {
         \App::abort(500);
     }
     $cid = env('APIGENCI_ID');
     $secret = env('APIGENCI_SECRET');
     $url = urlencode('https://' . $_SERVER['HTTP_HOST']);
     // Request access token
     $curl = \App\Models\Curl::post("https://github.com/login/oauth/access_token?client_id={$cid}&client_secret={$secret}&code={$code}&state={$state}&redirect_uri={$url}");
     parse_str($curl, $arr);
     // Invalid nonce, hacking attempt?
     if (!isset($arr['access_token'])) {
         //abort(403);
     }
     $token = $arr['access_token'];
     \Session::put('token', $token);
     $user = Apigenci\Model::githubApiGet('user');
     \Session::put('user', $user);
     $arr = ['id' => $user->id, 'email' => $user->email, 'login' => $user->login];
     // Check if user exists and add if not...
     try {
         \DB::connection('apigenci')->table('users')->insert($arr);
     } catch (\Exception $ex) {
         \DB::connection('apigenci')->table('users')->where('id', $user->id)->update($arr);
     }
     // Load authenticated screen
     return \Redirect::away('/');
 }
 // Logged in
 if (\Session::has('token')) {
     $repos = \Apigenci\Model::githubRepos();
     return \view('apigenci::dashboard', ['repos' => $repos]);
Example #2
0
<!DOCTYPE HTML>
<!--
        Eventually by HTML5 UP
        html5up.net | @n33co
        Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<?php 
$auth = Apigenci\Model::githubApiLoginUrl();
?>
<html lang="en">
    <head>
        <title>apigen.ci - CI for PHP docs</title>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
        <!--[if lte IE 8]>
        <script src="/assets/js/ie/html5shiv.js"></script><![endif]-->
        <link rel="stylesheet" href="/assets/css/main.css"/>
        <style>
            .doclink {
                border: 1px;
            }
        </style>
    </head>
    <body>

        <header id="header">
            <h1>apigen.ci <img src="/assets/img/logo64white.png"></h1>
            <p>
                A continuous documentation integration service for PHP<br/>
                powered by ApiGen.
            </p>