The issue occurs when a bit more restricted profile is being used, so I am still reviewing whether it is actually the cause or if it's something else.
n.b. we are working in a namespaced scratch org, trying to describe field such as IsActive works fine.
Edit: Seems that only sysadmin can describe this field, code:
public with sharing class descriptor {
@auraenabled public static void describer(){
Schema.User.LastPasswordChangeDate.getDescribe();
}
}
Edit 2: The root cause seems to be "Manage Users" permission on profile, which sort of makes sense but not really. I feel like it's a bug.
Edit 3: Managed to find a warkaround by catching and comparing sObjectException.getMessage()
, although that opened a new can of worms as there are tons of code that never anticipated a null describe 🙃
if (fToken != Schema.User.LastPasswordChangeDate){ ... }