I don't understand what's exactly your problem with the solution you choose, it should work well with {{ app.user }} except that app.user is an object, so you should have a toArray function into your user and call :
app_user = {{ app.user.toArray|json_encode() }};
Or call each parameter of the user like {{ app.user.id }}
Documentation : https://twig.sensiolabs.org/doc/filters/json_encode.html
You should use json_encode for your variables above, if you have a quote into one of your string it will break your javascript.
Example for profile:
<script type="text/javascript">
nickname = {{ profile.nickname|json_encode() }}; // Nickname will be a string
// 2nd solution if you have more informations related to profile
profile = {
nickname: {{ profile.nickname|json_encode() }},
lastname: {{ profile.lastname|json_encode() }}
};
// Profile is now an object with a nickname property.
// use profile.nickname on your javascripts
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…