<commit_before><?php

namespace OpenDominion\Http\Controllers\Auth;

use Illuminate\Foundation\Auth\RedirectsUsers;
use Illuminate\Http\Request;
use Mail;
use OpenDominion\Http\Controllers\AbstractController;
use OpenDominion\Mail\UserRegistrationMail;
use OpenDominion\Models\User;
use OpenDominion\Repositories\UserRepository;
use OpenDominion\Services\AnalyticsService;
use Session;
use Validator;

class RegisterController extends AbstractController
{
    use RedirectsUsers;

    /** @var UserRepository */
    protected $users;

    protected $redirectTo = '/';

    public function __construct(UserRepository $users)
    {
        $this->users = $users;
    }

    public function getRegister()
    {
        return view('pages.auth.register');
    }

    public function postRegister(Request $request)
    {
        $this->validator($request->all())->validate();

        $user = $this->create($request->all());

        try {
            // todo: move to job
            Mail::to($user->email)->send(new UserRegistrationMail($user));

        } catch (\Exception $e) {
            $request->session()->flash('alert-danger', 'Something went wrong with sending the registration mail. Your account was not created.');

            return redirect()->route('auth.register')
                ->withInput()
                ->withErrors([
                    $e->getMessage(),
                ]);
        }

        $user->save();

        // todo: fire laravel event
        $analyticsService = resolve(AnalyticsService::class);
        $analyticsService->queueFlashEvent(new AnalyticsService\Event(
            'user',
            'register'
        ));

        $request->session()->flash('alert-success', 'You have been successfully registered. An activation email has been dispatched to your address.');

        return redirect($this->redirectPath());
    }<commit_msg>But not on local<commit_after><?php

namespace OpenDominion\Http\Controllers\Auth;

use Illuminate\Foundation\Auth\RedirectsUsers;
use Illuminate\Http\Request;
use Mail;
use OpenDominion\Http\Controllers\AbstractController;
use OpenDominion\Mail\UserRegistrationMail;
use OpenDominion\Models\User;
use OpenDominion\Repositories\UserRepository;
use OpenDominion\Services\AnalyticsService;
use Session;
use Validator;

class RegisterController extends AbstractController
{
    use RedirectsUsers;

    /** @var UserRepository */
    protected $users;

    protected $redirectTo = '/';

    public function __construct(UserRepository $users)
    {
        $this->users = $users;
    }

    public function getRegister()
    {
        return view('pages.auth.register');
    }

    public function postRegister(Request $request)
    {
        $this->validator($request->all())->validate();

        $user = $this->create($request->all());

        try {
            // todo: move to job
            Mail::to($user->email)->send(new UserRegistrationMail($user));

        } catch (\Exception $e) {
            if (app()->environment() === 'local') {
                throw $e;
            }

            $request->session()->flash('alert-danger', 'Something went wrong with sending the registration mail. Your account was not created.');

            return redirect()->route('auth.register')
                ->withInput()
                ->withErrors([
                    $e->getMessage(),
                ]);
        }

        $user->save();

        // todo: fire laravel event
        $analyticsService = resolve(AnalyticsService::class);
        $analyticsService->queueFlashEvent(new AnalyticsService\Event(
            'user',
            'register'
        ));

        $request->session()->flash('alert-success', 'You have been successfully registered. An activation email has been dispatched to your address.');

        return redirect($this->redirectPath());
    }
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0, 'mean_word_length': 2.603932584269663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '1881180', 'n_tokens_mistral': 1010, 'n_tokens_neox': 986, 'n_words': 228}