PHP Authentication System - Login System
A Web Site Template with Login, Signup, Account Verification via Google Gmail, Password Reset and RememberMe Feature, CSRF Token and more.
All client/server communications made through REST API.
- Bootstrap latest version (5.3.x)
- Plain Vanilla Javascript (no JQuery)
- PHP (8.1.0)
No framework used
-
Clone the repository to local drive
-
Configure the MySQL database
-
Verify PHP version
-
Create a Client ID for Web application in Google Developpers Console
-
Obtain a refresh token from Google for your application
-
Modify config.php to include all parameters
Make sure that a local web server is installed (for example xampp on windows)
Try to access http://localhost/client/public/index.html with a web browser (for example chrome)
Make sure that a mysql database is installed
Create an empty database called syslogme
Import the file /server/config/database_backup.sql
into mysql database syslogme
Make sure that a PHP is installed (PHP version ">= 8.1.0")
Follow instructions provided at point 3 of : https://www.w3jar.com/php-send-emails-using-phpmailer/
Do not forget to specify [http://localhost/server/get_oauth_token.php] as Authorized redirect URI
Open a web browser and navigate to http://localhost/server/get_oauth_token.php
Follow instructions provided at point 4 of : https://www.w3jar.com/php-send-emails-using-phpmailer/
You should receive a refresh token from Google
Complete all settings in config.php, especially the settings bellow given as example:
// MYSQL
define('DB_TYPE', 'mysql');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'syslogme'); //change this value if needed
define('DB_CHARSET', 'utf8');
define('DB_USER', 'root'); //change this value if needed
define('DB_PASS', 'password'); //change this value if needed
// MAIL SYSTEM
define('MAIL_HOST', 'smtp.gmail.com');
define('MAIL_PORT', 587);
define('OAUTH_USER_EMAIL', 'yourmail@gmail.com'); //change this value with the email you used on point 4 to authenticate to google developpers console
define('OAUTH_CLIENT_ID', 'your-oauth-client-id.apps.googleusercontent.com'); //change this value with the one found in google developpers console
define('OAUTH_SECRET_KEY', 'your-oauth-secret-key'); //change this value with the one found in google developpers console
define('OAUTH_REFRESH_TOKEN', 'your-oauth-refresh-token'); //change this value with the one generated on point 5
Make sure that composer is installed
Open a command prompt on the local server and navigate to /server
directory
Verify that composer.json exist and that it contains:
{
"require": {
"google/apiclient": "^2.0",
"phpmailer/phpmailer": "^6.0",
"league/oauth2-google": "^4.0"
},
"scripts": {
"pre-autoload-dump": "Google\\Task\\Composer::cleanup"
},
"extra": {
"google/apiclient-services": [
"Gmail"
]
}
}
run composer update
from the /server
directory