Login
This function allows you to login users with few lines of code while being in control of the parameters and responses.
The database parameters from config file are;
table -> This value is the table with user details for authentication.
emailColumn -> This is the database name of the email/username column or the identifier you use when signing in.
passwordColumn -> This is the database name of the password column.
statusColumn -> This is optional. If you want to check if user if active. Pass the name of the status column here.
Usage
use Simcify\Auth;
Auth::login(
$username,
$password,
array(
"rememberme" => true,
"redirect" => "https://example.com",
"status" => "Active"
)
)
Parameters
Parameter
Required
Type
Description
$username
Yes
string
The username or email of the user.
$password
Yes
string
The password of the users without encryption.
$options
No
array
Explanation in the table below
$options parameter
This parameter gives you some extra control
Key
Type
Description
rememberme
boolean
true to remember user and false to not remember
redirect
string
Url to redirect after successful login
status
string
to check if user is active or matches are required column on database. Pass the value to match with the column set on config statusColumn above.
Response
Response is expected of redirect
was not set on that options parameter. Below is a sample response.
login successful
array(
"status" => "success",
"title" => "Login Successful",
"message" => "You have been logged in successfully"
)
Login failed
//incase of incorrect credentials
array(
"status" => "error",
"title" => "Incorrect Credentials",
"message" => "Incorrect username or password"
)
//incase username/email not found
array(
"status" => "error",
"title" => "User not found",
"message" => "Incorrect username or password"
)
//incase of account not active
array(
"status" => "error",
"title" => "Account inactive",
"message" => "Your account is not active."
)
Last updated