Giter VIP home page Giter VIP logo

ejabberd-extauth-php's People

Contributors

crubb avatar deceze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ejabberd-extauth-php's Issues

Can not make it work.

Hi,
I am using this library but cannot make it work. When I try to authenticate I get this message from ejabberd
extauth call '[<<"auth">>,<<"admin">>,<<"localhost">>,<<"123456">>]' didn't receive response.

I am using ejabberd version 17.01. Maybe it's a version issue as this script is pretty old.

here is my config:

auth_method: external
extauth_program: "/var/www/html/jabberd/index.php"

This is index.php

#!/usr/bin/php
<?php

require_once '/var/www/html/jabberd/EjabberdAuth.php';

$dbServer   = 'localhost';
$dbUser     = 'root';
$dbPassword = '12345';
$dbName     = 'ejabberd';

$pdo = new PDO('mysql:host=' . $dbServer . ';dbname=' . $dbName, $dbUser, $dbPassword);

new EjabberdAuth($pdo, 'ejabberd-auth.log');

And this is the EjabberdAuth class:

#!/usr/bin/php

<?php

require_once 'ejabberd_external_auth.php';

class EjabberdAuth extends EjabberdExternalAuth {

    /**
    * Actual authentication against the database
    */
    protected function authenticate($user, $server, $password) {
        $this->log('Authenticate method called .... ', LOG_INFO);
        $stmt = $this->db()->prepare("SELECT * FROM `users` WHERE username = ? AND password = ? ");
        $stmt->execute(array($user, $password));

        if($stmt->rowCount() > 0 )
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    /**
    * Check if a username already exists
    */
    protected function exists($user, $server) {
        $stmt = $this->db()->prepare("SELECT * FROM `users` WHERE username = ? ");
        $stmt->execute(array($user));
        if($stmt->rowCount() > 0 )
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

But nothing is logged and i am not getting any response. I made intentional errors in it to check if I get any error messages, which I get. So the script is being called. Can't figure out the issue.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.