Add Methode Authentication with User Manager
This commit is contained in:
parent
2a2fb1c856
commit
042c9a7a2f
@ -28,6 +28,8 @@
|
|||||||
return [
|
return [
|
||||||
['name' => 'administrator'],
|
['name' => 'administrator'],
|
||||||
['name' => 'user'],
|
['name' => 'user'],
|
||||||
|
['name' => 'otorisator'],
|
||||||
|
['name' => 'operator'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
|
'user_id',
|
||||||
|
'directorat_id',
|
||||||
|
'sub_directorat_id',
|
||||||
'password'
|
'password'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -6,22 +6,11 @@
|
|||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Modules\Usermanager\Entities\User;
|
||||||
use Modules\Usermanager\Http\Requests\LoginRequest;
|
use Modules\Usermanager\Http\Requests\LoginRequest;
|
||||||
|
|
||||||
class AuthenticatedSessionController extends Controller
|
class AuthenticatedSessionController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Display the login view.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\View\View
|
|
||||||
*/
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
addJavascriptFile('assets/js/custom/authentication/sign-in/general.js');
|
|
||||||
|
|
||||||
return view('usermanager::auth.login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming authentication request.
|
* Handle an incoming authentication request.
|
||||||
*
|
*
|
||||||
@ -38,6 +27,73 @@
|
|||||||
return redirect()->intended(RouteServiceProvider::HOME);
|
return redirect()->intended(RouteServiceProvider::HOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeUsermanager(Request $request)
|
||||||
|
{
|
||||||
|
$userArray = [];
|
||||||
|
$id = $request->email;
|
||||||
|
$passwd = $request->password;
|
||||||
|
$SERVER_ADDR = $request->ip();
|
||||||
|
$IPUserManager = $_ENV['IP_USER_MANAGER'];
|
||||||
|
$portUserManager = $_ENV['PORT_USER_MANAGER'];
|
||||||
|
$appId = $_ENV['APP_ID'];
|
||||||
|
|
||||||
|
$userData = verify_user($id, $passwd, $SERVER_ADDR, $IPUserManager, $portUserManager, $appId);
|
||||||
|
|
||||||
|
|
||||||
|
if (strlen($userData) > 1) {
|
||||||
|
$userRawArray = explode("\t", $userData);
|
||||||
|
foreach ($userRawArray as $rkey => $rval) {
|
||||||
|
[$key, $val] = explode('=', $rval);
|
||||||
|
$userArray[0][$key] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::where('user_id', '=', $request->email)->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $userArray[0]['NAMA_USER'],
|
||||||
|
'user_id' => $userArray[0]['KD_USER']
|
||||||
|
]);
|
||||||
|
|
||||||
|
switch ($userArray[0]['KD_GROUP']) {
|
||||||
|
case '001' :
|
||||||
|
$user->assignRole('administrator');
|
||||||
|
break;
|
||||||
|
case '007' :
|
||||||
|
$user->assignRole('operator');
|
||||||
|
break;
|
||||||
|
case '008' :
|
||||||
|
$user->assignRole('otorisator');
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
$user->assignRole('user');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Auth::loginUsingId($user->id, true);
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
}
|
||||||
|
return redirect()->intended(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the login view.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
addJavascriptFile('assets/js/custom/authentication/sign-in/general.js');
|
||||||
|
|
||||||
|
if($_ENV['METHOD_AUTH'] == 'usermanager'){
|
||||||
|
return view('usermanager::auth.login-usermanager');
|
||||||
|
} else {
|
||||||
|
return view('usermanager::auth.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy an authenticated session.
|
* Destroy an authenticated session.
|
||||||
*
|
*
|
||||||
|
69
Resources/views/auth/login-usermanager.blade.php
Normal file
69
Resources/views/auth/login-usermanager.blade.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<x-auth-layout>
|
||||||
|
|
||||||
|
<!--begin::Form-->
|
||||||
|
<form class="form w-100" novalidate="novalidate" id="kt_sign_in_form" data-kt-redirect-url="/" action="login">
|
||||||
|
@csrf
|
||||||
|
<!--begin::Heading-->
|
||||||
|
<div class="text-center mb-11">
|
||||||
|
<!--begin::Title-->
|
||||||
|
<h1 class="text-dark fw-bolder mb-3">
|
||||||
|
Sign In
|
||||||
|
</h1>
|
||||||
|
<!--end::Title-->
|
||||||
|
|
||||||
|
<!--begin::Subtitle-->
|
||||||
|
<div class="text-gray-500 fw-semibold fs-6">
|
||||||
|
Your Social Campaigns
|
||||||
|
</div>
|
||||||
|
<!--end::Subtitle--->
|
||||||
|
</div>
|
||||||
|
<!--begin::Heading-->
|
||||||
|
|
||||||
|
<!--begin::Input group--->
|
||||||
|
<div class="fv-row mb-8">
|
||||||
|
<!--begin::Email-->
|
||||||
|
<input type="text" placeholder="User ID" name="email" autocomplete="off" class="form-control bg-transparent" value=""/>
|
||||||
|
<!--end::Email-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--end::Input group--->
|
||||||
|
<div class="fv-row mb-3">
|
||||||
|
<!--begin::Password-->
|
||||||
|
<input type="password" placeholder="Password" name="password" autocomplete="off" class="form-control bg-transparent" value=""/>
|
||||||
|
<!--end::Password-->
|
||||||
|
</div>
|
||||||
|
<!--end::Input group--->
|
||||||
|
|
||||||
|
<!--begin::Wrapper-->
|
||||||
|
<div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">
|
||||||
|
<div></div>
|
||||||
|
|
||||||
|
<!--begin::Link-->
|
||||||
|
<a href="/forgot-password" class="link-primary">
|
||||||
|
Forgot Password ?
|
||||||
|
</a>
|
||||||
|
<!--end::Link-->
|
||||||
|
</div>
|
||||||
|
<!--end::Wrapper-->
|
||||||
|
|
||||||
|
<!--begin::Submit button-->
|
||||||
|
<div class="d-grid mb-10">
|
||||||
|
<button type="submit" id="kt_sign_in_submit" class="btn btn-primary">
|
||||||
|
@include('partials/general/_button-indicator', ['label' => 'Sign In'])
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<!--end::Submit button-->
|
||||||
|
|
||||||
|
<!--begin::Sign up-->
|
||||||
|
<div class="text-gray-500 text-center fw-semibold fs-6">
|
||||||
|
Not a Member yet?
|
||||||
|
|
||||||
|
<a href="/register" class="link-primary">
|
||||||
|
Sign up
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<!--end::Sign up-->
|
||||||
|
</form>
|
||||||
|
<!--end::Form-->
|
||||||
|
|
||||||
|
</x-auth-layout>
|
@ -19,39 +19,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--begin::Heading-->
|
<!--begin::Heading-->
|
||||||
|
|
||||||
<!--begin::Login options-->
|
|
||||||
<div class="row g-3 mb-9">
|
|
||||||
<!--begin::Col-->
|
|
||||||
<div class="col-md-6">
|
|
||||||
<!--begin::Google link--->
|
|
||||||
<a href="#" class="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100">
|
|
||||||
<img alt="Logo" src="{{ image('svg/brand-logos/google-icon.svg') }}" class="h-15px me-3"/>
|
|
||||||
Sign in with Google
|
|
||||||
</a>
|
|
||||||
<!--end::Google link--->
|
|
||||||
</div>
|
|
||||||
<!--end::Col-->
|
|
||||||
|
|
||||||
<!--begin::Col-->
|
|
||||||
<div class="col-md-6">
|
|
||||||
<!--begin::Google link--->
|
|
||||||
<a href="#" class="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100">
|
|
||||||
<img alt="Logo" src="{{ image('svg/brand-logos/apple-black.svg') }}" class="theme-light-show h-15px me-3"/>
|
|
||||||
<img alt="Logo" src="{{ image('svg/brand-logos/apple-black-dark.svg') }}" class="theme-dark-show h-15px me-3"/>
|
|
||||||
Sign in with Apple
|
|
||||||
</a>
|
|
||||||
<!--end::Google link--->
|
|
||||||
</div>
|
|
||||||
<!--end::Col-->
|
|
||||||
</div>
|
|
||||||
<!--end::Login options-->
|
|
||||||
|
|
||||||
<!--begin::Separator-->
|
|
||||||
<div class="separator separator-content my-14">
|
|
||||||
<span class="w-125px text-gray-500 fw-semibold fs-7">Or with email</span>
|
|
||||||
</div>
|
|
||||||
<!--end::Separator-->
|
|
||||||
|
|
||||||
<!--begin::Input group--->
|
<!--begin::Input group--->
|
||||||
<div class="fv-row mb-8">
|
<div class="fv-row mb-8">
|
||||||
<!--begin::Email-->
|
<!--begin::Email-->
|
||||||
|
@ -19,7 +19,12 @@
|
|||||||
Route::get('login', [AuthenticatedSessionController::class, 'create'])
|
Route::get('login', [AuthenticatedSessionController::class, 'create'])
|
||||||
->name('login');
|
->name('login');
|
||||||
|
|
||||||
Route::post('login', [AuthenticatedSessionController::class, 'store']);
|
if($_ENV['METHOD_AUTH'] == 'usermanager'){
|
||||||
|
Route::post('login', [AuthenticatedSessionController::class, 'storeUserManager']);
|
||||||
|
}else {
|
||||||
|
Route::post('login', [AuthenticatedSessionController::class, 'store']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
|
Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
|
||||||
->name('password.request');
|
->name('password.request');
|
||||||
|
Loading…
Reference in New Issue
Block a user