Wednesday, May 16, 2018

How to do auth without database in Laravel 5.6 - development

How to do auth without database in Laravel 5.6

I have to make default login in Laravel with: php artisan make:auth and I want to add 1 more authentication with API. In this auth API I don’t need database for login.

Is there any solution for this case?

I want to make custom provider and guard it but I am stuck at AlumniAuthProvider.php on AppAuth:

<?php

namespace AppAuth;

use IlluminateContractsAuthUser as UserContract;
use IlluminateContractsAuthAuthenticatable;
use IlluminateContractsAuthUserProvider;
use AppAuthUser;

class AlumniAuthProvider implements UserProvider {

    public function alumni()
    {           
    }

    public function retrieveById($identifier)
    {
    }

    public function retrieveByToken($identifier, $token)
    {
    }

    public function updateRememberToken(Authenticatable $user, $token)
    {
    }

    public function retrieveByCredentials(array $credentials)
    {
    }

    public function validateCredentials(Authenticatable $user, array $credentials)
    {       
    }
}

and Alumni.php on AppAuth:

<?php

namespace AppAuth;

use IlluminateContractsAuthAuthenticatable;
use IlluminateHttpRequest;

class Alumni implements Authenticatable
{
    public function getAuthIdentifierName()
    {
    }
    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier()
    {
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {        
    }

    /**
     * Get the token value for the "remember me" session.
     *
     * @return string
     */
    public function getRememberToken()
    {
    }

    /**
     * Set the token value for the "remember me" session.
     *
     * @param  string  $value
     * @return void
     */
    public function setRememberToken($value)
    {
    }

    /**
     * Get the column name for the "remember me" token.
     *
     * @return string
     */
    public function getRememberTokenName()
    {
    }
}

How could I make this custom API login?

In my opinion this code, which I made, is for second auth, or am I wrong? Maybe is there any other way to solve this problem?



from Laravel Questions and Answers https://laravelquestions.com/php/how-to-do-auth-without-database-in-laravel-5-6/
via Lzo Media

No comments:

Post a Comment