Fixed authentication with token save to database