-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting error on login #117
Comments
Hi @brinkonaut, I'm not able to reproduce this. Can you post your |
Somewhere in your application, serialization of an LDAP model is occurring -- when this happens, dates via the It seems conversion is failing somewhere, but will need to know more to assist, thanks! |
My config/auth.php:
]; My User Model has no $dates. |
Can you post your stack trace of the exception? |
Ah okay you're using Laravel Telescope, which is serializing the model. I'd still like to track down why conversions of the dates are failing... You're connecting to an Active Directory server I'm assuming? |
Ah, you are right, when I disable telescope it works. Thank you so much! Yes, its a Active Directory. |
No problem! Though, I still want this to work 100% with Telescope, so I'm going to patch this now to fallback if the date is unable to be converted. Would you be able to call a dump-n-die You'll have to open up your // vendor/directorytree/ldaprecord/src/Models/Concerns/HasAttributes.php
/**
* Add the date attributes to the attributes array.
*
* @param array $attributes
*
* @return array
*/
protected function addDateAttributesToArray(array $attributes)
{
foreach ($this->getDates() as $attribute => $type) {
if (!isset($attributes[$attribute])) {
continue;
}
// Add dd here:
dd($attributes[$attribute]);
$date = $this->serializeDate(
$this->asDateTime($type, $attributes[$attribute])
);
$attributes[$attribute] = Arr::wrap($date);
}
return $attributes;
} |
I'm wondering if your AD may have a different timestamp format, or something along those lines, but will need to see to be sure. |
|
Ah hang on it must be failing somewhere else, as I'm able to convert this successfully: use LdapRecord\Models\Attributes\Timestamp;
$time = new Timestamp('windows');
$carbon = $time->toDateTime('20200415102147.0Z'); Can you try this instead? /**
* Add the date attributes to the attributes array.
*
* @param array $attributes
*
* @return array
*/
protected function addDateAttributesToArray(array $attributes)
{
foreach ($this->getDates() as $attribute => $type) {
if (!isset($attributes[$attribute])) {
continue;
}
$date = $this->asDateTime($type, $attributes[$attribute]);
if ($date instanced Carbon) {
$date = $this->serializeDate($date);
} else {
// DD Here:
dd($attributes[$attribute]);
}
$attributes[$attribute] = Arr::wrap($date);
}
return $attributes;
} |
|
Perfect, thanks! Patching now... stay tuned for update 😄 |
Describe the bug
I have updated to the latest version.(1.2)
When I try to login im getting this error:
Argument 1 passed to LdapRecord\Models\Model::serializeDate() must implement interface DateTimeInterface, null given, called in /vendor/directorytree/ldaprecord/src/Models/Concerns/HasAttributes.php on line 105
When I change the code of this file to this:
protected function serializeDate(?DateTimeInterface $date) { return optional($date)->format($this->getDateFormat()); }
it works.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: