<commit_before><?php

namespace App\Http\Controllers\Sso;

use Auth;
use Input;
use Request;
use Redirect;
use App\Models\Sso\Token;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class Authentication extends \App\Http\Controllers\BaseController
{
    public function getLogin()
    {
        // Did we receive a token?  If we didn't get rid of them!
        if (!Input::get('token', false)) {
            die('SOME GENERIC ERROR');
        }

        // Check expired/invalid
        $ssoToken = Input::get('token');
        try {
            $ssoToken = Token::where('token', '=', $ssoToken)->firstOrFail();
        } catch (ModelNotFoundException $e) {
            die('TOKEN NOT FOUND');
        }

        // Got the token, let's do something.
        if (!Request::query('return')) {
            // Let's extend the expiry of this token for a minute or two....
            $ssoToken->expires_at = \Carbon\Carbon::now('GMT')->addMinutes(60)->toDateTimeString();
            $ssoToken->save();

            // Now let's send them off to the login shizzle!
            return Redirect::to('/mship/auth/login?returnURL='.urlencode(url('/sso/auth/login?token='.Request::query('token').'&return=1')).'&force='.Request::query('force', 0));
        } else {
            // We're successfully authenticated it seems... We can now return the access token.
            $ssoToken->account_id = $this->account->id;
            $ssoToken->expires_at = \Carbon\Carbon::now('GMT')->addSeconds(30)->toDateTimeString();
            $ssoToken->save();

            return Redirect::to($ssoToken->return_url);
        }
    }
}<commit_msg>Update current SSO to work with new auth<commit_after><?php

namespace App\Http\Controllers\Sso;

use Auth;
use Input;
use Request;
use Redirect;
use App\Models\Sso\Token;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class Authentication extends \App\Http\Controllers\BaseController
{
    public function getLogin()
    {
        // Did we receive a token?  If we didn't get rid of them!
        if (!Input::get('token', false)) {
            die('SOME GENERIC ERROR');
        }

        // Check expired/invalid
        $ssoToken = Input::get('token');
        try {
            $ssoToken = Token::where('token', '=', $ssoToken)->firstOrFail();
        } catch (ModelNotFoundException $e) {
            die('TOKEN NOT FOUND');
        }

        // Got the token, let's do something.
        if (!Request::query('return')) {
            // Let's extend the expiry of this token for a minute or two....
            $ssoToken->expires_at = \Carbon\Carbon::now('GMT')->addMinutes(60)->toDateTimeString();
            $ssoToken->save();

            // Now let's send them off to the login shizzle!
            $returnUrl = url('/sso/auth/login?token='.Request::query('token').'&return=1').'&force='.Request::query('force', 0);
            \Session::put('url.intended', $returnUrl);
            return redirect()->route('login');
        } else {
            // We're successfully authenticated it seems... We can now return the access token.
            $ssoToken->account_id = $this->account->id;
            $ssoToken->expires_at = \Carbon\Carbon::now('GMT')->addSeconds(30)->toDateTimeString();
            $ssoToken->save();

            return Redirect::to($ssoToken->return_url);
        }
    }
}
{'fraction_non_alphanumeric': 0.15338704864219635, 'fraction_numerical': 0.0035810205908683975, 'mean_word_length': 2.4414784394250515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '1358282', 'n_tokens_mistral': 1008, 'n_tokens_neox': 987, 'n_words': 229}