Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active June 15, 2016 07:11
Show Gist options
  • Save WietseWind/ba342cffa41027b9c3e13e2ac5d61945 to your computer and use it in GitHub Desktop.
Save WietseWind/ba342cffa41027b9c3e13e2ac5d61945 to your computer and use it in GitHub Desktop.
nodum.io - Social Profiles with nodum
{% do twig.noTemplate().addHeader('Content-type: application/json;') %}
{% trim %}
{% if socialprofile.getConnectedProviders %}
{% set profiles = [] %}
{% for p in socialprofile.getConnectedProviders %}
{% set profiles = profiles|merge({ (p) : socialprofile.getProfile(p) }) %}
{% endfor %}
{{ {
msg : 'hasProviders',
validAuth: true,
providers: socialprofile.getConnectedProviders,
profiles: profiles
}|json_encode }}
{% else %}
{{ { msg : 'noProviders', validAuth: false }|json_encode }}
{% endif %}
{% endtrim %}
<h1>Social Profile</h1>
{# ---- UITLOGGEN VERWERKEN ---- #}
{% if rest.get.logout %}
{% do socialprofile.doLogout(rest.get.logout) %}
{% endif %}
{# ---- INLOGGEN VERWERKEN ---- #}
{% if rest.get.loginUsing and rest.get.loginUsing in socialprofile.getProviders %}
<hr />
<h3>Inloggen met {{ rest.get.loginUsing|capitalize }}</h3>
{% if socialprofile.doAuth(rest.get.loginUsing) %}
<p class="alert alert-groen">Gelukt!</p>
{% else %}
<p class="alert alert-rood">Mislukt!</p>
<b>Details</b>
{{ socialprofile.error|pre }}
{% endif %}
{% endif %}
{# ---- LIJSTJE MET PROVIDERS + LOGINSTATUS ---- #}
<ul class="list-unstyled list-inline">
{% for provider in socialprofile.getProviders %}
<li>
{% if socialprofile.isConnected(provider) %}
<a href="{{ baselocation ~ folder }}/{{ page }}/logout:{{ provider }}/" class="text-rood">
<i class="fa fa-times"></i>
{{ provider|capitalize }} uitloggen
</a>
{% else %}
<a href="{{ baselocation ~ folder }}/{{ page }}/loginUsing:{{ provider }}/" class="text-groen">
<i class="fa fa-key"></i>
<b>Login met {{ provider|capitalize }}</b>
</a>
{% endif %}
</li>
{% endfor %}
</ul>
{# ---- DETAILS VAN DE PROFIELEN VAN DE INGELOGDE PROVIDERS ---- #}
{% if socialprofile.getConnectedProviders %}
<hr />
<h3>Account details</h3>
<ul id="myTab" class="nav nav-tabs" role="tablist">
{% for provider in socialprofile.getConnectedProviders %}
<li class="{{ loop.first ? 'active' }}"><a href="#{{ provider }}" role="tab" data-toggle="tab">{{ provider|capitalize }}</a></li>
{% endfor %}
</ul>
<div class="tab-content">
{% for provider in socialprofile.getConnectedProviders %}
<div id="{{ provider }}" class="tab-pane fade in {{ loop.first ? 'active' }}">
{{ socialprofile.getProfile(provider)|pre }}
</div>
{% endfor %}
</div>
<script>
$(document).ready(function(){
$('#myTab li a').click(function(e) {
e.preventDefault()
$(this).tab('show')
});
});
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment