laravel-authplus maintained by net-pioneer
Description
multi authentication for laravel
Author
Last update
2021/12/15 09:48
(dev-master)
Downloads
2
laravel-authplus
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.
Usages :
<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 !