Files
Investidor-V2/app/Models/User.php
T
Claude 52176edc21
tests / ci (push) Canceled after 0s
Registo: uma recusa do servidor de correio já não dá erro 500
Na produção, a 04/12/2026, o servidor de correio respondeu 550 «User
unknown» e o registo, já gravado, terminou em erro 500. A falha de envio
do email de confirmação passa a ficar registada e o investidor entra no
portal; pode pedir novo envio na página de confirmação.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
2026-12-04 22:27:38 +02:00

70 lines
2.3 KiB
PHP

<?php
namespace App\Models;
use Database\Factories\UserFactory;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Carbon;
use Laravel\Fortify\Contracts\PasskeyUser;
use Laravel\Fortify\PasskeyAuthenticatable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
/**
* @property int $id
* @property string $name
* @property string $email
* @property Carbon|null $email_verified_at
* @property int $portal_access_revision
* @property string $password
* @property string|null $two_factor_secret
* @property string|null $two_factor_recovery_codes
* @property Carbon|null $two_factor_confirmed_at
* @property string|null $remember_token
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*/
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
class User extends Authenticatable implements MustVerifyEmail, PasskeyUser
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
/**
* A mail server that refuses or fails (unknown mailbox, mistyped address,
* server down) must not turn a completed registration into an HTTP 500.
* The account exists; the failure is reported and the investor can ask
* for the email again from the verification page, which uses this path.
*/
public function sendEmailVerificationNotification(): void
{
try {
parent::sendEmailVerificationNotification();
} catch (TransportExceptionInterface $error) {
report($error);
}
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
/* @chisel-2fa */
'two_factor_confirmed_at' => 'datetime',
/* @end-chisel-2fa */
];
}
}