mirror of
https://github.com/pgmr3/synologySsoClientExamplePage.git
synced 2025-12-13 13:35:49 +01:00
93 lines
3.0 KiB
HTML
93 lines
3.0 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="de">
|
||
<head>
|
||
<!--
|
||
// ------------------------------------------------------------------------------
|
||
//
|
||
// © Copyright (с) 2023 License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
|
||
// author: https://github.com/pgmr3
|
||
// ------------------------------------------------------------------------------
|
||
-->
|
||
<meta charset="utf-8">
|
||
<title>some site</title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="description" content="">
|
||
<meta name="author" content="pgmr2.com">
|
||
<meta name="copyright" content="https://www.gnu.org/licenses/gpl-3.0.html" />
|
||
<script src="https://dsm.pgmr2.com/webman/sso/synoSSO-1.0.0.js"></script>
|
||
<script src="../js/myLoginScript.js" type="text/javascript"></script>
|
||
</head>
|
||
|
||
<body>
|
||
<div class="container">
|
||
<div class="form-signin">
|
||
<h1 class="form-signin-heading">some site</h1>
|
||
<h2 class="form-signin-heading" >your choice: back/home/menu/sign out </h2>
|
||
<INPUT TYPE="button" VALUE="back" onClick="history.go(-1);">
|
||
<button id="home-button" onclick="window.location.href = '/'" >home</button>
|
||
<button id="menu-button" onclick="window.location.href = '/my/'" >menu</button>
|
||
<button id="logout-button">sign out</button>
|
||
<br\>
|
||
<br\>
|
||
<div id="demo" >On this example page, the user is not automatically logged out after the session lifetime has expired, as the session lifetime stored in config.php is ignored.
|
||
However, deregistration occurs due to the loss of the sso registration.</div>
|
||
<br\>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
|
||
|
||
<script>
|
||
// globals
|
||
var Xlogedin = true;
|
||
|
||
// sign out event function is triggert
|
||
var myEventLogOut = function() {
|
||
console.log("myEventLogOut");
|
||
SYNOSSO.logout({
|
||
callback: logoutCallback
|
||
});
|
||
// since there is no response from SSYNOSSO.logout the following comes
|
||
doTestLogedin(onComplete ,null ,$startLogout=true).then ((data) => {
|
||
//console.log(data); //hier undefined, da asyncron
|
||
})
|
||
.catch(console.log);
|
||
window.location.replace("/"); // clear history
|
||
};
|
||
|
||
//callback von SYNOSSO.logout - will NOT fire!
|
||
function logoutCallback(response){
|
||
console.log("logoutCallback");
|
||
if(response) {
|
||
console.log (response);
|
||
alert("logout resonse in console");
|
||
Xlogedin = false;
|
||
}
|
||
}
|
||
|
||
//logout button
|
||
var logout_button = document.getElementById("logout-button");
|
||
if(logout_button !== null) logout_button.addEventListener('click' , myEventLogOut, false);
|
||
|
||
//menu button
|
||
var menu_button = document.getElementById("menu-button");
|
||
if(menu_button !== null) menu_button.addEventListener('click' , myEventMenu, false);
|
||
var myEventMenu= function() {
|
||
window.location.replace("/my/");
|
||
}
|
||
|
||
//callback doTestLogedin()
|
||
function onComplete(logedin){ // When the check loggedin completes, do this
|
||
console.log("loggedin: "+ logedin);
|
||
if (!logedin) window.location.replace("/"); // clear history
|
||
Xlogedin = logedin; //global
|
||
}
|
||
|
||
//Session expired? query cyclically
|
||
window.setInterval(function () {
|
||
if (Xlogedin) {
|
||
doTestLogedin(onComplete);
|
||
}
|
||
}, 1000); //milliseconds
|
||
|
||
</script> |