90 lines
2.8 KiB
PHP
90 lines
2.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Routing\Controller as BaseController;
|
||
|
use Illuminate\Support\Facades\Auth;
|
||
|
use Illuminate\Support\Facades\DB;
|
||
|
use Illuminate\Support\Facades\Hash;
|
||
|
use Illuminate\Support\Facades\Session;
|
||
|
use Nullix\CryptoJsAes\CryptoJsAes;
|
||
|
use Illuminate\Support\Facades\Request as Req;
|
||
|
|
||
|
class Controller extends BaseController
|
||
|
{
|
||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||
|
|
||
|
public function login(Request $request) {
|
||
|
$username = $request->username;
|
||
|
$password = $request->password;
|
||
|
$passDecrypt = "pmo123456";
|
||
|
$passwordDecrypted = CryptoJsAes::decrypt($password, $passDecrypt);
|
||
|
$data = DB::table('master_user')->where('user_code',$username)->first();
|
||
|
if(!is_null($data)) {
|
||
|
if (!Hash::check($passwordDecrypted, $data->password)){
|
||
|
return response()->json([
|
||
|
'rc' => 500,
|
||
|
'rm' => 'Password salah'
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
if(!$data->is_active) {
|
||
|
return response()->json([
|
||
|
'rc' => 500,
|
||
|
'rm' => 'User tidak aktif, Tolong Lapor ke administrator jika ingin mengaktifkan user kembali'
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
Session::put('id', $data->id);
|
||
|
Session::put('roleId', $data->role_id);
|
||
|
Auth::loginUsingId($data->id);
|
||
|
return response()->json([
|
||
|
'rc' => 0,
|
||
|
'rm' => 'User teridentifikasi',
|
||
|
'role' => $data->role_id,
|
||
|
]);
|
||
|
} else {
|
||
|
return response()->json([
|
||
|
'rc' => 500,
|
||
|
'rm' => 'Username Tidak Ditemukan'
|
||
|
]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function bsGetView($view,$param)
|
||
|
{
|
||
|
|
||
|
// $isAllow = false;
|
||
|
// $urlCheck = substr(\Request::getRequestUri(),1);
|
||
|
|
||
|
// $check = \DB::select("SELECT m.* from menu m
|
||
|
// join menu_privilege mp on mp.menu_uid = m.menu_uid
|
||
|
// where mp.group_id = ?",[Auth::user()->role]);
|
||
|
|
||
|
// foreach ($check as $key => $v) {
|
||
|
// if($v->url == '/'.$urlCheck){
|
||
|
// $isAllow = true;
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if ($urlCheck == '') {
|
||
|
$isAllow = true;
|
||
|
// }
|
||
|
|
||
|
if ($isAllow) {
|
||
|
if (Req::ajax()) {
|
||
|
return view('onlyContent')->nest('child', $view,$param);
|
||
|
}else {
|
||
|
return view('home')->nest('child', $view,$param);
|
||
|
}
|
||
|
}else{
|
||
|
return view('errors.404');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|