Error in authorize user function, fixing