<commit_before><?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use GuzzleHttp\Client;

use App\User;

class SsoController extends Controller {
	public function login(Request $req)
	{
		$client = new Client();
		$request = $client->createRequest('POST', 'http://dukcapil.pplbandung.biz.tm/oauth/access_token');
		$postBody = $request->getBody();
		// $postBody is an instance of GuzzleHttp\Post\PostBodyInterface
		$postBody->setField('grant_type', 'authorization_code');
		$postBody->setField('client_id', '5SLTJ3QStpkyeBcG');
		$postBody->setField('client_secret', '<KEY>');
		$postBody->setField('redirect_uri', 'http://localhost/PerizinanTerpadu/public/loginsso');
		$postBody->setField('code', $req->get('code'));

		$response = $client->send($request);
		$body = json_decode($response->getBody());
		$accessToken = $body->access_token;

		$client = new Client();
		$response = $client->get('http://dukcapil.pplbandung.biz.tm/api/penduduk/',['headers'=>['Authorization'=>'Bearer '.$accessToken]]);
		$data = $response->getBody();
		$json = json_decode($data);

		$user = User::where('id','=',$json->id)->first();
		if($user)
			$peran = $user->peran;<commit_msg>perbaiki url lagi<commit_after><?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use GuzzleHttp\Client;

use App\User;

class SsoController extends Controller {
	public function login(Request $req)
	{
		$client = new Client();
		$request = $client->createRequest('POST', 'http://dukcapil.pplbandung.biz.tm/oauth/access_token');
		$postBody = $request->getBody();
		// $postBody is an instance of GuzzleHttp\Post\PostBodyInterface
		$postBody->setField('grant_type', 'authorization_code');
		$postBody->setField('client_id', '5SLTJ3QStpkyeBcG');
		$postBody->setField('client_secret', '<KEY>');
		$postBody->setField('redirect_uri', \URL::to('loginsso'));
		$postBody->setField('code', $req->get('code'));

		$response = $client->send($request);
		$body = json_decode($response->getBody());
		$accessToken = $body->access_token;

		$client = new Client();
		$response = $client->get('http://dukcapil.pplbandung.biz.tm/api/penduduk/',['headers'=>['Authorization'=>'Bearer '.$accessToken]]);
		$data = $response->getBody();
		$json = json_decode($data);

		$user = User::where('id','=',$json->id)->first();
		if($user)
			$peran = $user->peran;
{'fraction_non_alphanumeric': 0.19740575597892177, 'fraction_numerical': 0.0016214025131738954, 'mean_word_length': 5.874651810584958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5102252', 'n_tokens_mistral': 909, 'n_tokens_neox': 864, 'n_words': 133}