<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">

<head>
    <metal:block fill-slot="top_slot"
                 tal:define="dummy python:request.set('disable_border',1);
                             disable_column_one python:request.set('disable_plone.leftcolumn',1);
                             disable_column_two python:request.set('disable_plone.rightcolumn',1);" />
 <metal:javascript fill-slot="javascript_head_slot">
   <link href="${portal_url}/++plone++castle/less/misc/secure-login.css?v=3"
         rel="stylesheet" type="text/css">
 <script src="${portal_url}/++plone++castle/components/secure-login.js?v=3">
 </script>
 </metal:javascript>
</head>

<body>
    <metal:main fill-slot="main">

    <div id="content-core">
        <metal:login define-macro="login"
            tal:define="auth nocall:context/acl_users/credentials_cookie_auth|context/cookie_authentication|nothing;
                        isURLInPortal nocall:context/portal_url/isURLInPortal;
                        login_template_ids python:'login login_success login_password login_failed login_form logged_in logout logged_out registered mail_password mail_password_form register require_login member_search_results pwreset_finish localhost'.split();
                        came_from request/came_from|request/HTTP_REFERER|nothing;
                        came_from_template_id python:came_from and context.plone_utils.urlparse(came_from)[2].split('/')[-1];
                        came_from python:test(came_from is not None and isURLInPortal(came_from) and came_from_template_id not in login_template_ids, came_from, None);
                        next request/next|nothing;
                        next python:test(next is not None and isURLInPortal(next), next, None);
                        errors options/state/getErrors;
                        ac_name auth/name_cookie|string:__ac_name;
                        ac_password auth/pw_cookie|string:__ac_password;
                        ac_persist auth/persist_cookie|nothing;
                        login_name python:request.get('login_name', request.get(ac_name, ''));
                        checkPermission nocall: context/portal_membership/checkPermission;
                        use_email_as_login python:context.portal_registry['plone.use_email_as_login'];
                        external_login_url python:context.portal_registry['plone.external_login_url'];
                        external_login_iframe python:context.portal_registry['plone.external_login_iframe'];
                        mail_password python:test(checkPermission('Mail forgotten password', context), portal_url + '/mail_password_form', '');
                        mail_password_url request/mail_password_url|nothing;
                        mail_password_url python:test(mail_password_url and isURLInPortal(mail_password_url), mail_password_url, mail_password);
                        join_actions python:context.portal_actions.listActionInfos('user/join', object=context) or [{}];
                        join python:join_actions[0].get('url');
                        join python:test(join and checkPermission('Add portal member', context), join, '');
                        join_url request/join_url|nothing;
                        join_url python:test(join_url is not None and isURLInPortal(join_url), join_url, join);
                        use_normal python:auth and not external_login_url;
                        use_iframe python:auth and external_login_url and external_login_iframe;
                        use_external python:auth and external_login_url and not external_login_iframe;
                        target request/target|nothing;
                        target python:test(target in ('_parent', '_top', '_blank', '_self'), target, None);
                        ztu modules/ZTUtils;
                        login nocall: context/@@secure-login">


            <div id="secure-login" data-options="${login/options}">
            </div>

            <div id="login-forgotten-password"
                 tal:condition="python:mail_password_url and use_normal">
                <strong i18n:translate="box_forgot_password_option">
                    Forgot your password?
                </strong>
                <p class="discreet"
                   i18n:translate="help_password_retrieval">
                    If you have forgotten your password,
                    <span i18n:name="click_here">
                        <a tal:define="mail_password_url python:mail_password_url+test(mail_password_url.find('?')==-1, '?', '&amp;')+ztu.make_query(userid=login_name)"
                            tal:attributes="href mail_password_url; target target;"
                           i18n:translate="label_click_here_to_retrieve">we can send you a new one</a></span>.
                </p>
            </div>

            <div id="login-new-user"
               tal:condition="python:join_url and use_normal">
                <strong i18n:translate="heading_new_user">
                New user?
                </strong>

                <p i18n:translate="description_no_account">
                If you do not have an account here, head over to the
                <span i18n:name="registration_form">
                    <a href=""
                       tal:define="join_url python:test(came_from, join_url+test(join_url.find('?')==-1, '?', '&amp;')+ztu.make_query(came_from=came_from), join_url);"
                       tal:attributes="href join_url; target target;"
                       i18n:translate="description_no_account_registration_linktext"
                        >registration form</a></span>.
                </p>

            </div>

        </metal:login>
    </div>

    </metal:main>
</body>
</html>
