mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
3b0cda1502
* Fixes for tests * fixes for permissions * Set default company on account creation * Ensure default company ID is registered in session variables * Implement a generic resolver to harvest an entity from encoded value * Laravel Telescope
34 lines
833 B
PHP
34 lines
833 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Traits;
|
|
|
|
use App\Models\User;
|
|
use App\Utils\Traits\UserSessionAttributes;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
trait VerifiesUserEmail
|
|
{
|
|
use UserSessionAttributes;
|
|
|
|
public function confirm($code)
|
|
{
|
|
$user = User::where('confirmation_code', $code)->first();
|
|
|
|
if ($user) {
|
|
|
|
$user->email_verified_at = now();
|
|
$user->confirmation_code = null;
|
|
$user->save();
|
|
|
|
$this->setCurrentCompanyId($user->companies()->first()->account->default_company_id);
|
|
|
|
Auth::loginUsingId($user->id, true);
|
|
|
|
return redirect()->route('dashboard.index')->with('message', trans('texts.security_confirmation'));
|
|
|
|
}
|
|
|
|
return redirect()->route('login')->with('message', trans('texts.wrong_confirmation'));
|
|
|
|
}
|
|
} |