Closed ghost closed 7 years ago
`<?php /**
define("LARAVELPATH", "/my/laravel/path"); /* without trailing slash / / i.e. : "/var/www/laravel" / define("LARAVEL_DB_HOSTNAME", "localhost"); define("LARAVEL_DB_NAME", "my_db"); define("LARAVEL_DB_USERNAME", "my_username"); define("LARAVEL_DB_PASSWORD", "my_pa55w0rd"); define("LARAVEL_DB_USER_TABLE", "usertable"); / laravel database "user" table name */
define("LARAVEL_SITE_URL", "http://homepage.com"); define("LARAVEL_LOGIN_URL", "http://loginpage.com"); define("LARAVEL_LOGOUT_URL", "http://logoutpage.com");
class LaravelAuth {
var $site_url = LARAVEL_SITE_URL; var $login_url = LARAVEL_LOGIN_URL; var $logout_url = LARAVEL_LOGOUT_URL; var $default_email = ''; var $admin_username = ''; public function checkPassword($username, $password) { /* Directly connecting to Laravel database to verify password */ $conn_str = "mysql:host=".LARAVEL_DB_HOSTNAME.";dbname=".LARAVEL_DB_NAME; try { $conn = new PDO($conn_str, LARAVEL_DB_USERNAME, LARAVEL_DB_PASSWORD); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "Connection to Laravel failed"; // $e->getMessage(); return false; } $stmt = $conn->prepare("SELECT id, username, password FROM " . LARAVEL_DB_USER_TABLE . " WHERE username = :username LIMIT 1"); $stmt->execute(array(':username' => $username)); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $row = $stmt->fetch(); if (!$row) { return false; } /* Include laravel password checker */ //include LARAVEL_PATH . '/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php'; include 'BcryptHasher.php'; // Save yourself the stress download a fresh copy of this file and include it in the Webzash Lib folder $bcryptHasher = new BcryptHasher(); $status = $bcryptHasher->compare($password, $row['password']); return $status; } public function getUserDetails() { return array('status' => FALSE); }
}`
I have added this link to the Wiki. Thanks.
https://github.com/prashants/webzash/wiki/Third-Party-Login
`<?php /**
define("LARAVELPATH", "/my/laravel/path"); /* without trailing slash / / i.e. : "/var/www/laravel" / define("LARAVEL_DB_HOSTNAME", "localhost"); define("LARAVEL_DB_NAME", "my_db"); define("LARAVEL_DB_USERNAME", "my_username"); define("LARAVEL_DB_PASSWORD", "my_pa55w0rd"); define("LARAVEL_DB_USER_TABLE", "usertable"); / laravel database "user" table name */
define("LARAVEL_SITE_URL", "http://homepage.com"); define("LARAVEL_LOGIN_URL", "http://loginpage.com"); define("LARAVEL_LOGOUT_URL", "http://logoutpage.com");
class LaravelAuth {
}`