Neuron-PHP

EmailVerifier
in package
implements IEmailVerifier

Email verification service.

Handles email verification token generation, validation, and account activation.

Table of Contents

Interfaces

IEmailVerifier
Email verification service interface

Properties

$_basePath  : string
$_random  : IRandom
$_settings  : SettingManager
$_tokenExpirationMinutes  : int
$_tokenRepository  : IEmailVerificationTokenRepository
$_userRepository  : IUserRepository
$_verificationUrl  : string

Methods

__construct()  : mixed
Constructor
cleanupExpiredTokens()  : int
Clean up expired tokens
resendVerification()  : bool
Resend verification email to a user by email address
sendVerificationEmail()  : bool
Send verification email to a user
setTokenExpirationMinutes()  : self
Set token expiration time in minutes
validateToken()  : EmailVerificationToken|null
Validate a verification token
verifyEmail()  : bool
Verify email and activate user account
sendEmail()  : void
Send verification email

Properties

$_tokenExpirationMinutes

private int $_tokenExpirationMinutes = 60

Methods

__construct()

Constructor

public __construct(IEmailVerificationTokenRepository $tokenRepository, IUserRepository $userRepository, SettingManager $settings, string $basePath, string $verificationUrl[, IRandom|null $random = null ]) : mixed
Parameters
$tokenRepository : IEmailVerificationTokenRepository

Token repository

$userRepository : IUserRepository

User repository

$settings : SettingManager

Settings manager with email configuration

$basePath : string

Base path for template loading

$verificationUrl : string

Base URL for email verification (token will be appended)

$random : IRandom|null = null

Random generator (defaults to cryptographically secure)

cleanupExpiredTokens()

Clean up expired tokens

public cleanupExpiredTokens() : int
Return values
int

Number of tokens deleted

resendVerification()

Resend verification email to a user by email address

public resendVerification(string $email) : bool
Parameters
$email : string

User's email address

Tags
throws
Exception

if email sending fails

Return values
bool

True if email was sent, false if user not found or already verified

sendVerificationEmail()

Send verification email to a user

public sendVerificationEmail(User $user) : bool

Generates a secure token, stores it, and sends an email to the user.

Parameters
$user : User

User to send verification email to

Tags
throws
Exception

if email sending fails

Return values
bool

True if verification email was sent

setTokenExpirationMinutes()

Set token expiration time in minutes

public setTokenExpirationMinutes(int $minutes) : self
Parameters
$minutes : int

Expiration time in minutes

Return values
self

verifyEmail()

Verify email and activate user account

public verifyEmail(string $plainToken) : bool
Parameters
$plainToken : string

Plain text token from URL

Tags
throws
Exception

if user update fails

Return values
bool

True if email was verified, false if token invalid or expired

sendEmail()

Send verification email

private sendEmail(User $user, string $plainToken) : void
Parameters
$user : User

User to send email to

$plainToken : string

Plain text token to include in URL

Tags
throws
Exception

if email sending fails


        
On this page

Search results