davide.cucurnia@vola.it
2024-02-09 61313b984d8934223caa7ea31ccc6ae7760499a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
    <script src="{{asset('js/jquery/jquery-3.6.0.min.js')}}"></script>
    <link href="{{asset('css/login.css?v=4')}}" rel="stylesheet" type="text/css">
    <style type="text/css">
        .c-half {
            width: 50%;
            float: left;
            height: auto;
        }
 
        .c-box {
            border: 1px solid black;
            padding: 20px;
            margin-bottom: 30px;
        }
 
        .grid {
            padding: 50px 0px;
        }
        .vfa-red-title {
            color: #e60000;
            font-family: vodafone_ltregular, Arial, Helvetica, sans-serif;
            font-size: 40px;
            font-weight: normal;
            text-align: center;
            margin-bottom: 26px;
            margin-top: 26px;
            line-height: 42px;
        }
 
        a {
            text-decoration:underline;
            display: block;
        }
 
    </style>
</head>
 
<body class="page_gray">
 
<div class="page_centerer">
 
    <div class="grid">
 
        <h1 class="vfa-red-title">Standalone FakeSSO Server</h1>
        <div class="c-box" id="status-info">
            @if (isset($loggedInfo["logged"]) && $loggedInfo["logged"] == "1")
                <p><b>Login:</b>Loggato con account {{$loggedInfo["username"]}}</p>
                <p><b>Profilo</b> numero: {{str_replace("xno:", "", $loggedInfo["token"])}}</p>
            @else
                <p><b>Login:</b> Non sei loggato</p>
            @endif
            <p><b>Controllo cookie:</b> {{(isset($loggedInfo["message"])) ? $loggedInfo["message"] : 'OK'}}</p>
        </div>
 
        <form id="fakesso" name="fakesso" action="" method="POST">
            @csrf
            <div class="c-box">
                <h2>Seleziona il profilo SSO su cui vuoi loggarti</h2>
                <p>Il login utilizza i cookie a livello di dominio, risulterai loggato su tutti i portali che utilizzano il dominio attuale ({{$domain}}).</p>
                <select id="sel_attiva">
                    @foreach (config('devtools.fake_sso_profiles') as $profileIndex => $profileContent)
                        <option value="{{$profileIndex}}">{{$profileContent['name']}}</option>
                    @endforeach
                </select>
                <input type="button" value="Attiva" id="btnAttiva"/>
                <div class="c-half"></div>
            </div>
            <div class="c-box">
                <p>Elimina dalla sessione i cookie FakeSSO.</p>
                <input type="button" value="Reset" id="btnReset"/>
 
            </div>
        </form>
        <div class="c-box">
            <a href="{{route('create-view')}}">Crea nuovo profilo sso</a>
        </div>
        <div class="c-box">
            <h2>Scorciatoie Portali</h2>
            @foreach (config('custom.portals_shortcuts',[]) as $websiteName => $websiteUri)
                <a href="{{$websiteUri}}" target="_blank">{{$websiteName}}</a>
            @endforeach
        </div>
    </div>
</div>
 
<script type="text/javascript">
    jQuery(document).ready(function () {
        let authorizationToken = $('input[name="_token"]').val();
 
        document.getElementById("btnAttiva").onclick = setCookies;
        document.getElementById("btnReset").onclick = delCookies;
 
        function callAjax(url, isSet) {
            document.getElementById('vola-loading').style.display = 'block';
            let profile = document.getElementById('sel_attiva').value;
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': authorizationToken,
                },
                type: "POST",
                url: url,
                dataType: "json",
                data: JSON.stringify({prof: profile}),
            }).done(function (msg) {
                document.getElementById('vola-loading').style.display = 'none';
                if (isSet) document.getElementById('status-info').innerHTML = '<b>Creati cookie per profilo xno:' + profile + '</b>';
            }).fail(function() {
                document.getElementById('vola-loading').style.display = 'none';
            });
        }
 
        function setCookies() {
            let setUri = location.origin + "{{$setUrl}}";
            callAjax(setUri, true);
        }
 
        function delCookies() {
            let logoutUri = location.origin + "{{$clearUrl}}";
            callAjax(logoutUri, false);
        }
 
    });
</script>
 
@include('vola_loading_animation')
</body>
</html>