Skip to content

Commit

Permalink
Merge pull request #244 from silinternational/feature/twig-style
Browse files Browse the repository at this point in the history
use recommended style for Twig templates
  • Loading branch information
briskt authored Jul 8, 2024
2 parents fbf1a21 + 1251a6b commit 99617a2
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 133 deletions.
9 changes: 3 additions & 6 deletions modules/expirychecker/public/about2expire.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@
$globalConfig = Configuration::getInstance();

$t = new Template($globalConfig, 'expirychecker:about2expire');
$t->data['formTarget'] = Module::getModuleURL('expirychecker/about2expire.php');
$t->data['formData'] = ['StateId' => $stateId];
$t->data['daysLeft'] = $state['daysLeft'];
$t->data['dayOrDays'] = (intval($state['daysLeft']) === 1 ? 'day' : 'days');
$t->data['expiresAtTimestamp'] = $state['expiresAtTimestamp'];
$t->data['accountName'] = $state['accountName'];
$t->data['form_target'] = Module::getModuleURL('expirychecker/about2expire.php');
$t->data['form_data'] = ['StateId' => $stateId];
$t->data['days_left'] = $state['daysLeft'];
$t->send();

Logger::info('expirychecker - User has been warned that their password will expire soon.');
6 changes: 2 additions & 4 deletions modules/expirychecker/public/expired.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@
$globalConfig = Configuration::getInstance();

$t = new Template($globalConfig, 'expirychecker:expired');
$t->data['formTarget'] = Module::getModuleURL('expirychecker/expired.php');
$t->data['formData'] = ['StateId' => $stateId];
$t->data['expiresAtTimestamp'] = $state['expiresAtTimestamp'];
$t->data['accountName'] = $state['accountName'];
$t->data['form_target'] = Module::getModuleURL('expirychecker/expired.php');
$t->data['form_data'] = ['StateId' => $stateId];
$t->send();

Logger::info('expirychecker - User has been told that their password has expired.');
6 changes: 0 additions & 6 deletions modules/expirychecker/src/Auth/Process/ExpiryDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ public function redirect2PasswordChange(
): void {
$sessionType = 'expirychecker';
/* Save state and redirect. */
$state['expiresAtTimestamp'] = $expiryTimestamp;
$state['accountName'] = $accountName;
$id = State::saveState(
$state,
'expirychecker:redirected_to_password_change_url'
Expand Down Expand Up @@ -359,8 +357,6 @@ public function redirectToExpiredPage(array &$state, string $accountName, int $e
]));

/* Save state and redirect. */
$state['expiresAtTimestamp'] = $expiryTimestamp;
$state['accountName'] = $accountName;
$state['passwordChangeUrl'] = $this->passwordChangeUrl;
$state['originalUrlParam'] = $this->originalUrlParam;

Expand Down Expand Up @@ -396,8 +392,6 @@ protected function redirectToWarningPage(array &$state, string $accountName, int
}

/* Save state and redirect. */
$state['expiresAtTimestamp'] = $expiryTimestamp;
$state['accountName'] = $accountName;
$state['passwordChangeUrl'] = $this->passwordChangeUrl;
$state['originalUrlParam'] = $this->originalUrlParam;

Expand Down
4 changes: 2 additions & 2 deletions modules/material/themes/material/default/other_mfas.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if otherOptions|length > 0 %}
{% if other_options|length > 0 %}
<div layout-children="column" child-spacing="center">
{# used type=button to avoid form submission on click since this is just used to display the ul #}
<button id="others" type="button" class="mdl-button mdl-js-button">
Expand All @@ -7,7 +7,7 @@
</span>
</button>
<ul class="mdl-menu mdl-js-menu mdl-menu--top-left" data-mdl-for="others">
{% for option in otherOptions %}
{% for option in other_options %}
{# TODO: Non-interactive elements should not be assigned mouse or keyboard event listeners. #}
<li class="mdl-menu__item" onclick="location.href = '{{ option.callback|raw }}'">
<span class="mdl-list__item-primary-content">
Expand Down
4 changes: 2 additions & 2 deletions modules/material/themes/material/default/selectidp-links.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

<div class="mdl-layout-spacer"></div>

{% if helpCenterUrl is defined and helpCenterUrl is not empty %}
{% if help_center_url is defined and help_center_url is not empty %}
<nav class="mdl-navigation">
<a href="{{ helpCenterUrl|e(html_attr) }}" target="_blank" rel="noopener" class="mdl-navigation__link">
<a href="{{ help_center_url|e(html_attr) }}" target="_blank" rel="noopener" class="mdl-navigation__link">
{{ '{selectidp-links:help}'|trans }}
</a>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
</header>
<main class="mdl-layout__content" layout-children="column">
<form layout-children="column">
{% for name, value in formData %}
{% for name, value in form_data %}
<input type="hidden" name="{{ name|e }}" value="{{ value|e }}">
{% endfor %}

<p class="mdl-typography--title margin">
{% if daysLeft < 2 %}
{% if days_left < 2 %}
{{ '{about2expire:expiring_in_a_day}'|trans }}
{% else %}
{{ '{about2expire:expiring_soon}'|trans({'%daysLeft%': daysLeft}) }}
{{ '{about2expire:expiring_soon}'|trans({'%daysLeft%': days_left}) }}
{% endif %}
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</header>
<main class="mdl-layout__content" layout-children="column">
<form layout-children="column">
{% for name, value in formData %}
{% for name, value in form_data %}
<input type="hidden" name="{{ name|e }}" value="{{ value|e }}">
{% endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<div class="mdl-card__title center">
<p class="mdl-card__subtitle-text">
{{ '{mfa:running_out_info}'|trans({'%numBackupCodesRemaining%':numBackupCodesRemaining}) }}
{{ '{mfa:running_out_info}'|trans({'%numBackupCodesRemaining%': num_backup_codes_remaining}) }}
</p>
</div>

Expand Down
14 changes: 7 additions & 7 deletions modules/material/themes/material/mfa/new-backup-codes.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</header>
<main class="mdl-layout__content" layout-children="column">
<form layout-children="column" method="post">
{% if newBackupCodes is not empty %}
{% if new_backup_codes is not empty %}
<h1 class="mdl-typography--display-1">
{{ '{mfa:new_codes_header}'|trans }}
</h1>
Expand All @@ -57,12 +57,12 @@
<div class="mdl-card mdl-shadow--8dp" style="min-height: 17em">
<div class="mdl-card__supporting-text ff-temp-flexbug-fix" layout-children="column" id="code-card">
<p class="fill-parent" layout-children="row">
<span flex>{{ '{mfa:account}'|trans({'%idpName%':idpName}) }}</span>
<span flex>{{ '{mfa:account}'|trans({'%idpName%': idp_name}) }}</span>
<em class="mdl-typography--caption">{{ "now"|date("M j, Y") }}</em>
</p>

<div class="code-container">
{% for newCode in newBackupCodes %}
{% for newCode in new_backup_codes %}
<code>☐ {{ newCode }}</code>
{% endfor %}
</div>
Expand Down Expand Up @@ -90,8 +90,8 @@
</button>

<a
href="data:text/plain,{{ codesForDownload }}"
download="{{ idpName }}-printable-codes.txt"
href="data:text/plain,{{ codes_for_download }}"
download="{{ idp_name }}-printable-codes.txt"
class="mdl-button mdl-button--primary"
>
{{ '{mfa:button_download}'|trans }}
Expand All @@ -112,7 +112,7 @@
</script>
<button class="mdl-button mdl-button--primary" type="button" onclick="copyCodesToClipboard(this)">
{{ '{mfa:button_copy}'|trans }}
<textarea class="out-of-sight">{{ codesForClipboard }}</textarea>
<textarea class="out-of-sight">{{ codes_for_clipboard }}</textarea>
</button>
</div>
</div>
Expand All @@ -131,7 +131,7 @@
<div class="mdl-card__supporting-text">
<p>
{{ '{mfa:new_codes_failed}'|trans }}
<a href="{{ mfaSetupUrl }}" target="_blank" rel="noopener">{{ mfaSetupUrl }}</a>
<a href="{{ mfa_setup_url }}" target="_blank" rel="noopener">{{ mfa_setup_url }}</a>
</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions modules/material/themes/material/mfa/out-of-backup-codes.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<div class="mdl-card__title center">
<p class="mdl-card__subtitle-text">
{% if hasOtherMfaOptions %}
{% if has_other_mfa_options %}
{{ '{mfa:has_options_besides_codes}'|trans }}
{% else %}
{{ '{mfa:has_no_more_options}'|trans }}
Expand All @@ -38,7 +38,7 @@
</div>

<div class="mdl-card__actions" layout-children="row">
{% if hasOtherMfaOptions %}
{% if has_other_mfa_options %}
<button name="continue" type="submit" class="mdl-button">
{{ '{mfa:button_later}'|trans }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
</div>
</div>

{% if errorMessage is not empty %}
{% if error_message is not empty %}
<div class="mdl-card__supporting-text" layout-children="column">
<p class="mdl-color-text--red error">
<i class="material-icons">error</i>

<span class="mdl-typography--caption">
{{ errorMessage|e }}
{{ error_message|e }}
</span>
</p>
</div>

<script>
ga('send', 'event', 'error', 'backupcode', '{{ errorMessage|e('js')|raw }}');
ga('send', 'event', 'error', 'backupcode', '{{ error_message|e('js')|raw }}');
</script>
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<div class="mdl-card__title center">
<p class="mdl-card__subtitle-text">
{{ '{mfa:manager_sent}'|trans({'%managerEmail%': managerEmail}) }}
{{ '{mfa:manager_sent}'|trans({'%managerEmail%': manager_email}) }}
</p>
</div>

Expand All @@ -42,19 +42,19 @@
</div>
</div>

{% if errorMessage is not empty %}
{% if error_message is not empty %}
<div class="mdl-card__supporting-text" layout-children="column">
<p class="mdl-color-text--red error">
<i class="material-icons">error</i>

<span class="mdl-typography--caption">
{{ errorMessage|e }}
{{ error_message|e }}
</span>
</p>
</div>

<script>
ga('send', 'event', 'error', 'managercode', '{{ errorMessage|e('js')|raw }}');
ga('send', 'event', 'error', 'managercode', '{{ error_message|e('js')|raw }}');
</script>
{% endif %}

Expand Down
8 changes: 4 additions & 4 deletions modules/material/themes/material/mfa/prompt-for-mfa-totp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>

<div class="mdl-card__title center">
{{ '{mfa:account}'|trans({'%idpName%': idpName}) }}
{{ '{mfa:account}'|trans({'%idpName%': idp_name}) }}
</div>

<div class="mdl-card__supporting-text" layout-children="column">
Expand All @@ -40,19 +40,19 @@
</div>
</div>

{% if errorMessage is not empty %}
{% if error_message is not empty %}
<div class="mdl-card__supporting-text" layout-children="column">
<p class="mdl-color-text--red error">
<i class="material-icons">error</i>

<span class="mdl-typography--caption">
{{ errorMessage|e }}
{{ error_message|e }}
</span>
</p>
</div>

<script>
ga('send', 'event', 'error', 'totp', '{{ errorMessage|e('js')|raw }}');
ga('send', 'event', 'error', 'totp', '{{ error_message|e('js')|raw }}');
</script>
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

{{ include('header.twig') }}

<script src="{{ browserJsPath }}"></script>
<script src="{{ browser_js_path }}"></script>

<script>
function verifyWebAuthn() {
const loginChallenge = {{ mfaOptionData|raw }};
const loginChallenge = {{ mfa_option_data|raw }};
SimpleWebAuthnBrowser.startAuthentication(loginChallenge.publicKey).then(submitForm).catch(handleError);
}
Expand Down Expand Up @@ -65,7 +65,7 @@
</script>
</head>

<body class="gradient-bg" onload="{{ supportsWebAuthn ? 'verifyWebAuthn()' : '' }}">
<body class="gradient-bg" onload="{{ supports_web_authn ? 'verifyWebAuthn()' : '' }}">
<div class="mdl-layout mdl-layout--fixed-header fill-viewport">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
Expand All @@ -88,7 +88,7 @@
</h1>
</div>

{% if supportsWebAuthn %}
{% if supports_web_authn %}
<div class="mdl-card__title">
<p class="mdl-card__subtitle-text">
{{ '{mfa:webauthn_instructions}'|trans }}
Expand All @@ -102,17 +102,17 @@
</div>
{% endif %}

{% if errorMessage is not empty %}
{% if error_message is not empty %}
<script>
ga('send', 'event', 'error', 'webauthn', '{{ errorMessage|e('js')|raw }}');
ga('send', 'event', 'error', 'webauthn', '{{ error_message|e('js')|raw }}');
</script>
{% endif %}
<div class="mdl-card__supporting-text" layout-children="column">
<p class="mdl-color-text--red error {{ errorMessage is empty ? 'hide' : 'show' }}">
<p class="mdl-color-text--red error {{ error_message is empty ? 'hide' : 'show' }}">
<i class="material-icons">error</i>

<span class="mdl-typography--caption">
{{ errorMessage|e }}
{{ error_message|e }}
</span>
</p>
</div>
Expand All @@ -123,7 +123,7 @@
<button
type="button"
onclick="verifyWebAuthn()"
class="mdl-button mdl-color-text--red {{ errorMessage is empty ? 'hide' : 'show' }}"
class="mdl-button mdl-color-text--red {{ error_message is empty ? 'hide' : 'show' }}"
>
{{ '{mfa:button_try_again}'|trans }}
</button>
Expand Down
6 changes: 3 additions & 3 deletions modules/material/themes/material/mfa/send-manager-mfa.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

<div class="mdl-card__title center">
<p class="mdl-card__subtitle-text">
{{ '{mfa:manager_info}'|trans({'%managerEmail%':managerEmail})|raw }}
{{ '{mfa:manager_info}'|trans({'%managerEmail%': manager_email})|raw }}
</p>
</div>

{% if errorMessage is not empty %}
{% if error_message is not empty %}
<div class="mdl-card__supporting-text" layout-children="column">
<p class="mdl-color-text--red error">
<i class="material-icons">error</i>

<span class="mdl-typography--caption">
{{ errorMessage|e }}
{{ error_message|e }}
</span>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

<span flex></span>

{% if mfaLearnMoreUrl is not empty %}
{% if mfa_learn_more_url is not empty %}
<a
href="{{ mfaLearnMoreUrl }}"
href="{{ mfa_learn_more_url }}"
target="_blank"
rel="noopener"
class="mdl-button mdl-button--primary margin"
Expand Down
Loading

0 comments on commit 99617a2

Please sign in to comment.