LoginController.php
This handles user registration and login functionality, supporting both traditional username/password and social login with Google and Facebook.
loginUser
loginUserpublic function loginUser(Request $request)
{
// Retrieve username and password from the request
$username = $request->input('username');
$password = $request->input('password');
// Query the UserAccount model for a user with matching username and password
$userAccount = UserAccount::where('username', $username)
->where('password', $password)
->first();
// Check if a user account was found
if (isset($userAccount)) {
// Check if the user account is verified
if ($userAccount->verified == false) {
// User account is not verified, return a response indicating verification failure
$response = [
'SUCCESS' => 2, // 2 indicates verification failure
];
return $response;
} else {
// User account is verified, return a success response with user details
$response = [
'SUCCESS' => 1, // 1 indicates successful login
'ID' => $userAccount->id,
'USERNAME' => $userAccount->username
];
return $response;
}
} else {
// No user account found, return a response indicating login failure
$response = [
'SUCCESS' => 0, // 0 indicates login failure
];
return $response;
}
}authenticateGoogleAccountForLogin
authenticateGoogleAccountForLoginloginGoogleUser
loginGoogleUserauthenticateFacebookAccountForLogin
authenticateFacebookAccountForLoginloginFacebookUser
loginFacebookUserLast updated