- Timestamp:
- 08/26/24 12:43:09 (3 months ago)
- Branches:
- main
- Children:
- 092fcda
- Parents:
- 768f473
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/SessionsController.php
r768f473 r69e9f5d 19 19 $password = $credentials['password']; 20 20 $badge_no = $credentials['badge_no']; 21 // mozhe da se najavi kako policaec i kako officer, znaeme koj e koj po znachkata 22 21 23 $policeman = true; 22 $exists = DB::select('select * from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 23 $pass = DB::select('select p_password from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 24 if($exists == null) { 25 $exists = DB::select('select * from officer where o_badge_no = :badge_no;', ['badge_no' => $badge_no]); 26 $pass = DB::select('select o_password from officer where o_badge_no = :badge_no;', ['badge_no' => $badge_no]); 24 $is_policeman = DB::select('select * from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 25 $is_officer = DB::select('select * from officer where o_badge_no = :badge_no;', ['badge_no' => $badge_no]); 26 if($is_officer==null && $is_policeman==null) { 27 return back()->withErrors(['password' => 'Invalid credentials']); 28 } 29 if($is_officer!=null) { 30 $pass = DB::select('select o_password from officer where o_badge_no = :o_badge_no;', ['o_badge_no' => $badge_no]); 27 31 $policeman = false; 28 } 29 if($exists == null) { 30 return back()->withErrors(['badge_no' => 'Invalid badge_no']); 32 } else { 33 $pass = DB::select('select p_password from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 31 34 } 32 35 … … 36 39 } 37 40 38 39 41 if ($value == $password) { 40 42 // Authentication passed … … 42 44 Session::put('is_policeman', $policeman); 43 45 if($policeman){ 44 Session::put('p _id', $exists[0]->p_id);46 Session::put('pe_id', $is_policeman[0]->pe_id); 45 47 } else { 46 Session::put('pe_id', $ exists[0]->pe_id);48 Session::put('pe_id', $is_officer[0]->pe_id); 47 49 } 48 50 return view('welcome'); … … 56 58 { 57 59 Session::forget('badge_no'); 60 Session::forget('p_id'); 61 Session::forget('pe_id'); 58 62 Session::forget('is_policeman'); 59 63 return redirect('/login');
Note:
See TracChangeset
for help on using the changeset viewer.