I know that my solution is wrong, but can someone help me with correct syntax how decrypt my string and log in ?
Laravel API resived code
and store encrypted in Database
api route
Route::post('data','DataImport@Insert');
controller
use Illuminate\Support\Facades\Crypt;
function Insert(Request $request)
{
$user=new User();
$user->code=Crypt::encrypt($request->input('code'));
return $user->save();
}
Auth\Controller
use Illuminate\Support\Facades\Crypt;
public function postLogin(Request $request)
{
request()->validate([
'id_message' => 'required',
'code' => 'required',
]);
$credentials = $request->only('id_message', 'code');
$decrypted = $request->input('code');
$request->session()->flash('success');
if ($user=User::where($credentials)->first()) {
if (\Crypt::decrypt($user->code) == $decrypted) {
Auth::login($user);
return redirect()->intended('dashboard')->with('success');
}
}
//dd($decrypted);
return Redirect::back()->with('error');
}
dd($decrypted);
array:1 [▼
"code" => "123456"
]
decrypted code
is in correct value. No error in laravel.log
only message code does not match.
thanks for any help.
(solution with hash, dont help me with this problem)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire