<%@language = "javascript" %>
<% /*
    $Revision$
    $Id$

    File:           login_email.asp
    Description:    Pre-login scherm
    Parameters:
    Context:
    Note:           Vraagt e-mail adres/inlogcode
                    Bepaalt aan de hand daarvan (aut_idp.aut_idp_emailwhitelist)
                    welke sso voor jou geschikt is.

*/
ANONYMOUS_Allowed = 1;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="./login.inc" -->
<!--#include file="../shared/useragent.inc" -->
<%
if (Request.QueryString.Count > 0)
{   // relaxed omdat mensen nog wel eens een bookmark naar de inlogpagina inclusief
    // HMAC leggen en we daar niet al te moeilijk over willen doen.
    var is_ok = protectQS.verify( { relaxed: true } ); // Voorkom Un-validated Redirects and Forwards
    if (!is_ok)
    {
        // De hmac is fout. Dan strippen we alles van de url af zodat het toch weer veilig is.
        Response.Redirect(rooturl + "/");
    }
}

var fac_lang = getQParamSafe("fac_lang", "").toUpperCase(); // overrule via param
if (fac_lang && fac_lang in lcl.languages)
    Session("user_lang") = fac_lang;

var ret_page = getQParam("ret_page", "");
var querystring = getQParam("querystring", "");

FCLTHeader.Requires({plugins: ["jQuery"], js:["jQuery-ui.js"]});

checkUserAgent(); // heeft device capability bits gezet
%>
<html id="loginhtml">
<head>
<%
    FCLTHeader.Generate()
%>
 <script>
    <%
        if (Application("otap_environment") == "O" && user_key > 0)
        {
            %>
            alert("<%=safe.jsstring("Ietwat vreemd: in het inlogscherm terwijl je gewoon bekend bent als '{0}' met key {1}".format(Session("userident"), String(user_key)))%>");
            <%
        }
    %>
    window.parent.document.title = "<%=L("lcl_facilitor_ie_title")%>";
    function login_callback(json)
    {
        if (json.success)
        {
            window.location.href = json.redirect_uri;
        }
    }

    function do_submit()
    {
        $.post($("form[name=ifl_f]")[0].action, $("[name=ifl_f]").serialize(), FcltCallbackAndThen(login_callback), "json");
    }
 </script>
</head>

<body id="loginbody">

<div id="myportalteaser">
    <%=L("lcl_logon_teaser")%>
</div>
<div id="logindiv" class="loginbox">
<form name="ifl_f" action="<%=rooturl%>/appl/aut/login_email_save.asp" method="post" onsubmit='do_submit();return false;' autocomplete="off">
  <input type="hidden" id="mobile" name="mobile" value="0">
  <div class="illustration"><%=I("fa-user-lock", { fastyle: "fas"})%></div>
  <div id="logindiv">
<%
    if (S("language_toggles").length > 1)
    {
      if (fac_lang && fac_lang in lcl.languages)
      { %>
      <input type="hidden" id="fac_lang" name="fac_lang" value="<%=fac_lang%>">
<%    } %>
      <div class="form-group" id="langtoggle"><%
       var qs = buildTransitParam(["ret_page", "querystring"]);
       for (lang in S("language_toggles"))
       {
         var code = S("language_toggles")[lang];
         var desc = lcl.languages[code];
       %><a class="col-form-control" href="<%=protectQS.create(rooturl+"/appl/aut/login_email.asp?fac_lang="+code+qs)%>"><img title="<%=safe.htmlattr(desc)%>" alt="<%=safe.htmlattr(desc)%>" src="<%=rooturl%>/appl/pictures/<%=code%>.png"></a><%
       }
    %></div>
<%  } %>

      <div class="form-floating">
        <input class="form-control required" type="text" maxlength="200" id="prsemail" name="prs_email" placeholder="<%=L("lcl_prs_person_email")%>">
        <label for="prsemail"><%=L("lcl_prs_person_email")%></label>
      </div>
<%
    var buttons = [ { title: L("lcl_logon"), action: "do_submit()", importance: 1, icon: "fa-sign-in" } ];
    CreateButtons(buttons, { entersubmit: true, vertical: true, display: "flex" });
%>

</div>
<% IFACE.FORM_END(); %>
</form>
</div>

<div id="loginfooter"><%=L("lcl_facilitor_footer")%></div>
</body>
</html>
<% ASPPAGE_END(); %>
