The enchantment on Thor's hammer laid out by Odin prevents anyone "not worthy" to wield it as we can see on the famous Arthuresque scene on Avengers: Age of Ultron.
This enchantment, pronounced by Odin in the first Thor movie goes:
Whosoever holds this hammer, be he worthy, shall posses the power of Thor.
One of the biggest moments of Avengers: Endgame comes close to the end when
Captain America picks up Thor's Hammer and gains the power of Thor, while Thor screams "I knew it".
However, given at the beginning of Thor: Ragnarok we see that:
Odin dies of old age.
Since the enchantment of the hammer comes from Odin and, from my understanding, it is that enchantment that grants the power of Thor to anyone weilding the hammer, shouldn't the enchantment laid out on top of the hammer have dissipated and therefore those not have happened?