You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use \Illuminate\Http\Request;
|
|
use \Laravel\Passport\Passport;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
/**
|
|
* Description of OAuthController
|
|
*
|
|
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
|
*/
|
|
class OAuthController extends Controller
|
|
{
|
|
public function resource(Request $request)
|
|
{
|
|
if (is_null($request->user())) {
|
|
return redirect('/');
|
|
}
|
|
|
|
$user = $request->user();
|
|
|
|
$response = new \stdClass();
|
|
$response->resourceOwnerId = $user->id;
|
|
|
|
if ($user->tokenCan('fullname')) {
|
|
$response->name = $user->first_name;
|
|
$response->patronymic = $user->middle_name;
|
|
$response->lastname = $user->last_name;
|
|
}
|
|
|
|
if ($user->tokenCan('email')) {
|
|
$response->email = $user->email;
|
|
}
|
|
|
|
if ($user->tokenCan('birthday')) {
|
|
$response->birthday = $user->birthday;
|
|
}
|
|
|
|
return json_encode($response);
|
|
}
|
|
}
|