AuthenticationController
extends BaseController
in package
Table of Contents
Methods
- __construct() : mixed
- completeRegistration() : void
- This function is used to display Google 2FA password setup page for user registration.
- forgotpassword() : string
- This function is used to display the forgot password page with authentication state management.
- getContentBlank() : stdClass
- This function is used to generate metadata content using panel configuration constants.
- getContentForgotPassword() : stdClass
- This function is used to generate metadata content for the forgot password page.
- getContentLogin() : stdClass
- This function is used to generate metadata content for the login page.
- getUser() : User|string
- This function is used to validate user credentials and return user object or error response.
- loginCheck() : bool|string
- This function is used to validate user login credentials and handle two-factor authentication.
- loginPage() : string
- This function is used to display the login page with authentication state management.
- loginSubmit() : RedirectResponse|string
- This function is used to process user login authentication with reCAPTCHA validation.
- newPassword() : JsonResponse
- This function is used to update user password with validation and token regeneration.
- otpSumbit() : JsonResponse
- This function is used to validate OTP for password reset verification.
- resetPasswordConfirmUser() : RedirectResponse
- This function is used to process password reset confirmation via activation link.
- resetPasswordUser() : JsonResponse
- This function is used to process password reset request and send OTP via email.
- scanGenerate() : RedirectResponse
- This function is used to process Google 2FA QR code verification and complete authentication setup.
- setCookie() : array<string|int, mixed>
- This function is used to set authentication cookie for QR code-based two-factor authentication.
- signOut() : RedirectResponse
- This function is used to logout user and clear all authentication data.
Methods
__construct()
public
__construct() : mixed
completeRegistration()
This function is used to display Google 2FA password setup page for user registration.
public
completeRegistration(Request $request) : void
This method renders the Google 2FA password setup interface where users can complete their two-factor authentication registration. It passes the user's password, username, and authentication token to the view for the QR code generation process.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
void —Renders the Google 2FA password setup view and terminates execution
forgotpassword()
This function is used to display the forgot password page with authentication state management.
public
forgotpassword(Request $request) : string
This method handles the forgot password page display with comprehensive authentication checks similar to the login page. It validates existing sessions, checks remember-me cookies, processes authentication errors, retrieves global settings and menu data, and renders the forgot password page with appropriate content and styling.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
string —The rendered HTML content for the forgot password page
getContentBlank()
This function is used to generate metadata content using panel configuration constants.
public
getContentBlank() : stdClass
This method creates a standardized metadata object containing SEO-friendly information using the panel name from configuration constants. It retrieves the panel name from config and sets all metadata properties to this value for consistent branding across the application.
Tags
Return values
stdClass —Object containing panel metadata with properties: meta_description, page_title, meta_title, meta_keywords
getContentForgotPassword()
This function is used to generate metadata content for the forgot password page.
public
getContentForgotPassword() : stdClass
This method creates a standardized metadata object containing SEO-friendly information for the forgot password page, including meta description, page title, meta title, and meta keywords. All values are set to 'Forgot Password' for consistency.
Return values
stdClass —Object containing forgot password page metadata with properties: meta_description, page_title, meta_title, meta_keywords
getContentLogin()
This function is used to generate metadata content for the login page.
public
getContentLogin() : stdClass
This method creates a standardized metadata object containing SEO-friendly information for the login page, including meta description, page title, meta title, and meta keywords. All values are set to 'Login' for consistency.
Return values
stdClass —Object containing login page metadata with properties: meta_description, page_title, meta_title, meta_keywords
getUser()
This function is used to validate user credentials and return user object or error response.
public
getUser(string $email, string $password, Request $request) : User|string
This method performs user authentication by checking email existence and password verification using Laravel's Hash facade. It returns the user object on successful authentication or redirects to login page with error messages for security purposes (not revealing which credential failed).
Parameters
- $email : string
-
The user's email address
- $password : string
-
The user's password
- $request : Request
-
The HTTP request instance
Tags
Return values
User|string —Returns user object on success or login page on failure
loginCheck()
This function is used to validate user login credentials and handle two-factor authentication.
public
loginCheck(Request $request, string $username, string $password) : bool|string
This method performs comprehensive user authentication including credential validation, two-factor authentication checks, session token management, and remember-me functionality. It handles various 2FA scenarios including Google Authenticator, force 2FA requirements, and cookie-based authentication.
Parameters
- $request : Request
-
The HTTP request instance
- $username : string
-
The user's email or username
- $password : string
-
The user's password
Tags
Return values
bool|string —Returns true on successful authentication or login page on failure
loginPage()
This function is used to display the login page with authentication state management.
public
loginPage(Request $request) : string
This method handles the login page display with comprehensive authentication checks. It checks for existing user sessions, validates remember-me cookies, processes authentication errors and reCAPTCHA errors, retrieves global settings and menu data, and renders the login page with appropriate content and styling.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
string —The rendered HTML content for the login page
loginSubmit()
This function is used to process user login authentication with reCAPTCHA validation.
public
loginSubmit(Request $request) : RedirectResponse|string
This method handles the login form submission with comprehensive validation. It validates reCAPTCHA response, processes login credentials, performs authentication checks, logs successful login activities, and redirects authenticated users to the dashboard or returns to login page with errors.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
RedirectResponse|string —Either redirects to dashboard or returns login page with errors
newPassword()
This function is used to update user password with validation and token regeneration.
public
newPassword(Request $request) : JsonResponse
This method handles the final step of the password reset process by validating the new password and confirmation, hashing the password securely, updating the user record, and regenerating the session token for security purposes.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
JsonResponse —JSON response indicating password update success or failure
otpSumbit()
This function is used to validate OTP for password reset verification.
public
otpSumbit(Request $request) : JsonResponse
This method verifies the one-time password (OTP) entered by the user during the password reset process. It validates the OTP against the stored verification records and returns appropriate success or error responses for the password reset flow.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
JsonResponse —JSON response indicating OTP validation success or failure
resetPasswordConfirmUser()
This function is used to process password reset confirmation via activation link.
public
resetPasswordConfirmUser([string|null $activation_id = null ][, string|null $email = null ], Request $request) : RedirectResponse
This method handles password reset confirmation through activation links sent via email. It validates the activation ID and email parameters, processes the reset request, and manages the password reset flow with proper error handling and security measures.
Parameters
- $activation_id : string|null = null
-
The unique activation identifier from reset link
- $email : string|null = null
-
The user's email address from reset link
- $request : Request
-
The HTTP request instance
Tags
Return values
RedirectResponse —Redirects to appropriate page based on validation
resetPasswordUser()
This function is used to process password reset request and send OTP via email.
public
resetPasswordUser(Request $request) : JsonResponse
This method handles the password reset process by validating the user's email, generating a secure OTP, creating password reset records, checking email verification limits, and sending the OTP via email with personalized content. It includes rate limiting to prevent abuse and comprehensive error handling.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
JsonResponse —JSON response indicating success or specific error
scanGenerate()
This function is used to process Google 2FA QR code verification and complete authentication setup.
public
scanGenerate(Request $request) : RedirectResponse
This method handles the verification of one-time passwords from Google Authenticator during the two-factor authentication setup process. It validates the OTP against the user's secret key, sets authentication cookies, updates user records, and redirects to dashboard upon successful verification or back with errors on failure.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
RedirectResponse —Redirects to dashboard on success or back with errors
setCookie()
This function is used to set authentication cookie for QR code-based two-factor authentication.
public
setCookie(string $user_password, Request $request) : array<string|int, mixed>
This method creates a secure authentication cookie for users during the QR code setup process for two-factor authentication. The cookie is set with a 7-hour expiration time and contains the user's authentication token.
Parameters
- $user_password : string
-
The user's authentication token
- $request : Request
-
The HTTP request instance
Tags
Return values
array<string|int, mixed> —Array containing the user cookie value for database storage
signOut()
This function is used to logout user and clear all authentication data.
public
signOut(Request $request) : RedirectResponse
This method performs a comprehensive logout by invalidating the user's authentication session, regenerating session tokens for security, clearing remember-me cookies, and redirecting to the login page with a success message.
Parameters
- $request : Request
-
The HTTP request instance
Tags
Return values
RedirectResponse —Redirects to login page with success message