Changeset 8a258ab
- Timestamp:
- 08/26/24 13:20:24 (4 months ago)
- Branches:
- main
- Children:
- 5372778
- Parents:
- 092fcda
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/SessionsController.php
r092fcda r8a258ab 8 8 use Illuminate\Support\Facades\DB; 9 9 use Illuminate\Support\Facades\Session; 10 use Illuminate\Support\Facades\Hash; 10 11 11 12 class SessionsController extends Controller 12 13 { 14 function verifyPassword($inputPassword, $storedHash, $salt) 15 { 16 $hashedInputPassword = crypt($inputPassword . $salt, $storedHash); 17 18 return $hashedInputPassword === $storedHash; 19 } 13 20 public function store() 14 21 { … … 29 36 if($is_officer!=null) { 30 37 $pass = DB::select('select o_password from officer where o_badge_no = :o_badge_no;', ['o_badge_no' => $badge_no]); 38 $salt = DB::select('select salt from officer where o_badge_no = :o_badge_no;', ['o_badge_no' => $badge_no]); 31 39 $policeman = false; 32 40 } else { 33 41 $pass = DB::select('select p_password from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 42 $salt = DB::select('select salt from policeman where badge_no = :badge_no;', ['badge_no' => $badge_no]); 43 34 44 } 35 45 … … 38 48 break; // Break after the first key-value pair 39 49 } 40 41 if ($value == $password) { 50 foreach ($salt[0] as $key => $val) { 51 $value2 = $val; 52 break; // Break after the first key-value pair 53 } 54 if ($this->verifyPassword($password, $value, $value2)) { 42 55 // Authentication passed 43 56 Session::put('badge_no', $badge_no);
Note:
See TracChangeset
for help on using the changeset viewer.