net-pioneer/laravel-authplus

There is no license information available for the latest version (dev-master) of this package.

multi authentication for laravel

dev-master 2021-12-15 08:48 UTC

This package is auto-updated.

Last update: 2025-07-15 16:32:01 UTC


README

Multi authentication for laravel v1.0.0 Based On LiveWire
It's a first version of laravel Multi Authentication, which you can authenticate many types of users (admin/customer/user).
net-pioneer (pouya)

note :
First Rival it's my first project which i decided to publish it for public usage. so if something wrong happened in my codes, plz fix it by yourself and share it to us LOL.

Features :
- Captcha
- Two Factor Authentication (based on your Configuration Like SMS/Email/Google authenticator)
- Multi Authentication
- Auto Generation DB tables
- User Verifications (BASIC and Simple one)
- and etc.
Installation :
composer require net-pioneer/laravel-authplus

Or copy the hole files into your Project-name/Packages/netpioneer/authplus
and then add codes bellow to your main composer "netpioneer\\authplus\\": "packages/netpioneer/authplus/src/"
"autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/",
            "netpioneer\\authplus\\": "packages/netpioneer/authplus/src/"
        }
    },

Usages :

1:
php artisan vendor:publish --provider=netpioneer\authplus\Providers\AuthplusServiceProvider
2:
php artisan migrate
NOTE : Before to run migration you should config your auth.php in config folder.like guards,verifications and etc.
3:
php artisan make:livewire Login
NOTE : you should know LiveWire Basics . you i write it short
4:
View :
<form wire:submit.prevent="submit">
        @csrf
        @if(!$twofactor)
        <input type="text" name="username" wire:model.defer="username">
        <br>
        <input type="password" name="password" wire:model.defer="password">
        <br>
        <img src="/ap/ap_captcha?t={{time()}}" /><br>
        <input type="text" name="captcha" wire:model.defer="captcha">
        @else
        <input type="text" name="twofactor_input" wire:model.defer="twofactor_input">
        @endif
        <input type="submit">
    </form>

inside LiveWire Class:

public function submit(){
        $guardName = 'admin';
        try {
            $this->res = app(AuthPlusAuthenticateUser::class)->twofactor($this->twofactor_input)->captcha($this->captcha)->Authenticate($guardName, $this->username, $this->password, true);
            $this->err = $this->res;
            return redirect()->away(AuthPlusLogics::getHomePage());
        }catch (LoginFailedExecption $exception){
            if($exception->getStatus() == LoginStatusEnum::TwoFactorRequired){
                $this->twofactor = true;
                $this->err = 'two factor';
            }else {
                $this->err = "login failed > " . $exception->getStatus() . " - data : " . (is_array($exception->getData()) ? implode(",",$exception->getData()) : $exception->getData());
            }
        }
    }

You could able to Customize your Auth stuff in Service Provider because everything are on default :

AuthPlus::AuthenticateMethod(AuthPlusAuthenticateUserDefualt::class);
AuthPlus::RedirectAuthenticated(AuthPlusRedirectAuthenticatedCustom::class);
AuthPlus::TwoFactorAuthenticator(AuthPlusTwoFactorSmsAuthenticator::class);

Router : if open route were enabled on auth config file there is no need to create route for each path Lol except the Index file should be managed on you !

Donate:
Good news ! If you enjoyed this package you could donate me by donating USDT to my wallet ! A Coffee or etc.
USDT wallet Address (TRC20) : TBFJ3YirXc7vwwuRNeqhcBcQziB3h9bPbs