lundi 28 mars 2016

How to authenticate without database in Laravel 5.2?

I have tried the following code to authenticate in Laravel 5.2. But I don't know how to make login true. I tried Auth::login(true) after if statement but it is not working properly. I have found some articles about this topic but i couldn't find a detailed example.

public static function Login($email,$password)
{
    $fp = fsockopen ( "www.mydomain.com" , 110 );
    if (!$fp) {
        return "Bağlantı Hatası";
    }
    $trash = fgets ( $fp, 128 );
    fwrite ( $fp, "USER ".$email."\r\n" );
    $trash = fgets ( $fp, 128 );
    fwrite ( $fp, "PASS ".$password."\r\n" );
    $result = fgets ( $fp, 128 );
    if(substr ( $result, 0, 3 ) == '+OK')
        return true; //user will be logged in and then redirect
    else
        return false;
}

If it is possible, could you please add a code here that how to make auth true?

P.S. I can retrieve the user information using email with a simple query after login.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire