This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/views/includes/external.pug

71 lines
2.3 KiB
Plaintext
Raw Normal View History

.external-login
2019-08-08 12:33:58 +00:00
if auth.facebook
div#fb-root
script.
window.fbAsyncInit = function() {
FB.init({
appId : '#{auth.facebook}',
cookie : true,
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.10&appId=1124948240960869";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
fb:login-button(scope="public_profile,email", onlogin="checkLoginState();" data-max-rows="1", data-size="large", data-button-type="login_with", data-show-faces="false", data-auto-logout-link="false", data-use-continue-as="false")
2019-08-08 12:33:58 +00:00
if auth.google
2020-01-28 22:02:01 +00:00
script(src="https://apis.google.com/js/platform.js?onload=startApp", async, defer)
2018-01-29 12:00:06 +00:00
a.login-btn.google-login.float-lg-right
2019-10-26 09:54:51 +00:00
i.fab.fa-fw.fa-google
2017-10-13 16:18:17 +00:00
span Log in With Google
script.
var googleUser = {};
var startApp = function() {
gapi.load('auth2', function(){
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: '#{auth.google}',
2020-01-28 21:56:24 +00:00
cookie_policy: 'single_host_origin',
2017-10-13 16:18:17 +00:00
fetch_basic_profile: true
2020-01-28 22:00:49 +00:00
}).then(function () {
attachSignin(document.querySelector('.google-login'));
}, function (e) {
console.error(e);
2017-10-13 16:18:17 +00:00
});
});
};
function attachSignin(element) {
auth2.attachClickHandler(element, {},
function (googleUser) {
let profile = googleUser.getBasicProfile();
let dataTree = {
id_token: googleUser.getAuthResponse().id_token,
name: profile.getName(),
email: profile.getEmail(),
image: profile.getImageUrl()
};
if (window.googlePOST) {
window.googlePOST(dataTree);
}
}, function(error) {
alert('Failed to log you in using Google.');
});
}
2019-08-08 12:33:58 +00:00
if auth.twitter
2018-01-29 12:00:06 +00:00
a.login-btn.twitter-login.login-dialog-pop.float-lg-right(href="/api/external/twitter/login")
2019-10-26 09:54:51 +00:00
i.fab.fa-fw.fa-twitter
2017-08-03 15:49:31 +00:00
span Log in With Twitter
2019-08-08 12:33:58 +00:00
if auth.discord
2018-01-29 12:00:06 +00:00
a.login-btn.discord-login.login-dialog-pop.float-lg-right(href="/api/external/discord/login")
2019-10-26 09:54:51 +00:00
i.fab.fa-fw.fa-discord
2017-08-03 15:49:31 +00:00
span Log in With Discord