2018-10-24 12:24:09 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-10-24 12:24:09 +02:00
|
|
|
|
|
|
|
namespace App\Http\Controllers\Traits;
|
|
|
|
|
|
|
|
use App\Models\User;
|
2018-11-03 02:01:40 +01:00
|
|
|
use App\Utils\Traits\UserSessionAttributes;
|
2018-10-29 04:16:17 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2018-10-24 12:24:09 +02:00
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* Class VerifiesUserEmail
|
|
|
|
* @package App\Http\Controllers\Traits
|
|
|
|
*/
|
2018-10-24 12:24:09 +02:00
|
|
|
trait VerifiesUserEmail
|
|
|
|
{
|
2018-11-03 02:01:40 +01:00
|
|
|
use UserSessionAttributes;
|
2018-10-24 12:24:09 +02:00
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @param $code
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
2018-10-24 12:24:09 +02:00
|
|
|
public function confirm($code)
|
|
|
|
{
|
2019-04-18 07:01:40 +02:00
|
|
|
//$user = User::where('confirmation_code', $code)->first();
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
if ($user = User::whereRaw("BINARY `confirmation_code`= ?", $code)->first()) {
|
2018-10-24 12:24:09 +02:00
|
|
|
$user->email_verified_at = now();
|
|
|
|
$user->confirmation_code = null;
|
|
|
|
$user->save();
|
|
|
|
|
2019-04-18 07:01:40 +02:00
|
|
|
return response()->json(['message' => ctrans('texts.security_confirmation')]);
|
|
|
|
//return redirect()->route('dashboard.index')->with('message', ctrans('texts.security_confirmation'));
|
2018-10-24 12:24:09 +02:00
|
|
|
}
|
|
|
|
|
2019-04-18 07:01:40 +02:00
|
|
|
return response()->json(['message' => ctrans('texts.wrong_confirmation')]);
|
|
|
|
|
|
|
|
//return redirect()->route('login')->with('message', ctrans('texts.wrong_confirmation'));
|
2018-10-24 12:24:09 +02:00
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|