fix skit2
This commit is contained in:
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
use App\Dashboard;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Login Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles authenticating users for the application and
|
||||||
|
| redirecting them to your home screen. The controller uses a trait
|
||||||
|
| to conveniently provide its functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest')->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login()
|
||||||
|
{
|
||||||
|
$cawangans = Http::get(config('api.url').'/api/cawangan')->json();
|
||||||
|
return view('auth.login',compact('cawangans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authenticate(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => 'required|string|email',
|
||||||
|
'password' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$credentials = $request->only('email', 'password');
|
||||||
|
|
||||||
|
if (Auth::guard('web')->attempt($credentials)) {
|
||||||
|
$auth_user = Auth::guard('web')->user();
|
||||||
|
$api_url = config('api.url');
|
||||||
|
if($auth_user['roles'] == 'operasi' || $auth_user['roles'] == 'admin'){
|
||||||
|
|
||||||
|
return redirect()->route('home');
|
||||||
|
}else if($auth_user['roles'] == 'akaun'){
|
||||||
|
return redirect()->route('akaunhome');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return redirect('login')->with('error', 'Oppes! You have entered invalid credentials');
|
||||||
|
}
|
||||||
|
// if($auth_user['roles'] == 'teller'){
|
||||||
|
// if($auth_user['role_harian'] == 'teller'){
|
||||||
|
// $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||||
|
// // return view('homepage.'.$auth_user['role_harian'].'.home',compact('cawangan_info','api_url'));
|
||||||
|
// return redirect()->route('home');
|
||||||
|
// }elseif($auth_user['role_harian'] == 'penilai'){
|
||||||
|
// $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||||
|
// $gadaian_semasa = Http::get(config('api.url') . '/api/gadaiansemasa/'. $auth_user['cawangan'])->json();
|
||||||
|
// $gadaian_belumserah = Http::get(config('api.url') . '/api/gadaiansemasa/belum_serah/'. $auth_user['cawangan'])->json();
|
||||||
|
// // return view('homepage.'.$auth_user['role_harian'].'.home',compact('cawangan_info','gadaian_semasa','gadaian_belumserah','api_url'));
|
||||||
|
// return redirect()->route('home');
|
||||||
|
// }else{
|
||||||
|
// return view('not_assign');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// elseif($auth_user['roles'] == 'pc' || $auth_user['roles'] == 'ppc'){
|
||||||
|
// $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||||
|
// // return view('homepage.khazanah.home',compact('cawangan_info','api_url'));
|
||||||
|
// return redirect()->route('home');
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||||
|
// // return view('homepage.'.$auth_user['roles'].'.home',compact('cawangan_info','api_url'));
|
||||||
|
// return redirect()->route('home');
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('login')->with('error', 'Oppes! You have entered invalid credentials');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loginDashboard(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => 'required|string|email',
|
||||||
|
'password' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$credentials = $request->only('email', 'password');
|
||||||
|
|
||||||
|
if (Auth::guard('dashboard')->attempt($credentials,true)) {
|
||||||
|
$auth_user = Auth::guard('dashboard')->user();
|
||||||
|
|
||||||
|
$user_login['nama'] = $auth_user['name'];
|
||||||
|
$user_login['email'] = $auth_user['email'];
|
||||||
|
$user_login['password'] = $auth_user['password'];
|
||||||
|
$user_login['icno'] = $auth_user['no_kp'];
|
||||||
|
$user_login['apitoken'] = $auth_user['remember_token'];
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'user' => $user_login
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
//if authentication is unsuccessfull, notice how I return json parameters
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Invalid Email or Password',
|
||||||
|
], 401);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logoutDashboard(Request $res)
|
||||||
|
{
|
||||||
|
$login_detail = Dashboard::where([['no_kp','=',$res->nokp],['remember_token','=',$res->header('Authorization')]])->first();
|
||||||
|
// dd($login_detail);
|
||||||
|
if ($login_detail) {
|
||||||
|
// dd($login_detail);
|
||||||
|
$logout_user = Dashboard::where([['no_kp','=',$res->nokp],['remember_token','=',$res->header('Authorization')]])->update(array(
|
||||||
|
'remember_token' => null
|
||||||
|
));
|
||||||
|
// dd($logout_user);
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Logout successfully'
|
||||||
|
]);
|
||||||
|
}else {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Unable to Logout'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(){
|
||||||
|
Auth::logout();
|
||||||
|
Session::flush();
|
||||||
|
return Redirect::to('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+10518
-36
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
@@ -18944,6 +18944,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
|
|
||||||
this.caw = this.$kodcaw;
|
this.caw = this.$kodcaw;
|
||||||
this.axios.get('/api/check/cawangan').then(function (response) {
|
this.axios.get('/api/check/cawangan').then(function (response) {
|
||||||
|
console.log(response.data);
|
||||||
_this.cawangan = response.data;
|
_this.cawangan = response.data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -18954,7 +18955,6 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
namacawangan: function namacawangan(cawangannama) {
|
namacawangan: function namacawangan(cawangannama) {
|
||||||
console.log(cawangannama);
|
|
||||||
var namcaw = '';
|
var namcaw = '';
|
||||||
|
|
||||||
if (this.cawangan.length > 0) {
|
if (this.cawangan.length > 0) {
|
||||||
@@ -105760,7 +105760,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = JSON.parse('{"_from":"axios@^0.21","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"axios@^0.21","name":"axios","escapedName":"axios","rawSpec":"^0.21","saveSpec":null,"fetchSpec":"^0.21"},"_requiredBy":["#DEV:/","#USER"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_shasum":"c67b90dc0568e5c1cf2b0b858c43ba28e2eda575","_spec":"axios@^0.21","_where":"C:\\\\laragon\\\\www\\\\adminpkb","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}');
|
module.exports = JSON.parse('{"_args":[["axios@0.21.4","C:\\\\laragon\\\\www\\\\adminpkb"]],"_development":true,"_from":"axios@0.21.4","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"axios@0.21.4","name":"axios","escapedName":"axios","rawSpec":"0.21.4","saveSpec":null,"fetchSpec":"0.21.4"},"_requiredBy":["#DEV:/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_spec":"0.21.4","_where":"C:\\\\laragon\\\\www\\\\adminpkb","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}');
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
this.caw = this.$kodcaw
|
this.caw = this.$kodcaw
|
||||||
|
|
||||||
this.axios.get('/api/check/cawangan').then(response => {
|
this.axios.get('/api/check/cawangan').then(response => {
|
||||||
|
console.log(response.data)
|
||||||
this.cawangan = response.data;
|
this.cawangan = response.data;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -50,7 +51,6 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
namacawangan: function(cawangannama){
|
namacawangan: function(cawangannama){
|
||||||
console.log(cawangannama)
|
|
||||||
let namcaw = '';
|
let namcaw = '';
|
||||||
if(this.cawangan.length >0)
|
if(this.cawangan.length >0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user