<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="714842678556-imnjrjvhrvf0rrm9kl4hmuptkv78d1n7.apps.googleusercontent.com">
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>

<form method="POST" class="mb-0">
    <label>Email:</label>
    <input class="form-control mb-2" type="email" name="user_email" required>
    <label>Password:</label>
    <input class="form-control mb-2" type="password" name="user_password" required>

    <label>
        <input type="checkbox" name="remember_me"> Remember me
    </label>
    <button type="submit" name="login_submit" class="btn btn-primary w-100 mt-2 mb-0">Войти</button>
{*    <div class="g-signin2" data-onsuccess="onSignIn"></div>
    <button onclick="facebookLogin()">Войти через Facebook</button>*}

    {if isset($error_message)}
        <p>{$error_message}</p>
    {/if}
</form>

<script type="text/javascript">
    function onSignIn(googleUser) {
        var profile = googleUser.getBasicProfile();
        console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
        console.log('Name: ' + profile.getName());
        console.log('Image URL: ' + profile.getImageUrl());
        console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
    }
</script>

<script>
    function facebookLogin() {
        FB.login(function(response) {
            if (response.authResponse) {
                console.log('Добро пожаловать! Мы получаем ваши данные...');
                FB.api('/me', { fields: 'id,name,email' }, function(response) {
                    console.log(response);
                    // отправьте данные на сервер для обработки
                });
            } else {
                console.log('Пользователь отменил вход');
            }
        });
    }
/*
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '2952410211578408',
            cookie     : true,
            xfbml      : true,
            version    : 'v12.0'
        });
    };

    (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 = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));*/
</script>


<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '958076862448332',
            cookie     : true,
            xfbml      : true,
            version    : 'v12.0'
        });

        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 = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>
