Honestly I have no idea if this function can be reused in any other scenario.
There is one backend implementation using it this way and the basic assumption is that this approach will work for other auth backends - let's see how this code changes once we have another one. :wink: