Skip to content

Commit b8435c4

Browse files
committed
refactor: migrated 2FA logic (#3834)
1 parent 614f100 commit b8435c4

File tree

10 files changed

+197
-530
lines changed

10 files changed

+197
-530
lines changed

phpmyfaq/.htaccess

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
112112
RewriteRule ^(search|open-questions|glossary|overview|login|privacy|contact)\.html$ index.php?action=$1 [L,QSA]
113113
RewriteRule ^404\.html$ index.php [L,QSA]
114114
RewriteRule ^(login) index.php?action=login [L,QSA]
115+
RewriteRule ^(authenticate|check|logout|token) index.php [L,QSA]
115116
# start page
116117
RewriteRule ^index.html$ index.php [L,QSA]
117118
# a solution ID page
@@ -144,7 +145,7 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
144145
# Authentication services
145146
RewriteRule ^services/webauthn(.*) index.php [L,QSA]
146147
# User pages
147-
RewriteRule ^user/(ucp|bookmarks|request-removal|logout|register)/?$ index.php?action=$1 [L,QSA]
148+
RewriteRule ^user/(ucp|bookmarks|request-removal|register)/?$ index.php?action=$1 [L,QSA]
148149
# Administration API
149150
RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA]
150151
# Administration pages

phpmyfaq/assets/src/frontend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ document.addEventListener('DOMContentLoaded', (): void => {
9797
handleRegister();
9898
handleWebAuthn();
9999

100-
// Masonry on the startpage
100+
// Masonry on the start page
101101
const masonryElement: HTMLElement | null = document.querySelector('.masonry-grid');
102102
if (masonryElement) {
103103
new Masonry(masonryElement, { columnWidth: 0 });

phpmyfaq/assets/templates/default/index.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
{% endif %}
9696
<li><a class="dropdown-item" href="./user/request-removal">{{ msgUserRemoval }}</a></li>
9797
<li><hr class="dropdown-divider"></li>
98-
<li><a class="dropdown-item" href="./user/logout?csrf={{ csrfLogout }}">{{ msgLogoutUser }}</a></li>
98+
<li><a class="dropdown-item" href="./logout?csrf={{ csrfLogout }}">{{ msgLogoutUser }}</a></li>
9999
{% endif %}
100100
</ul>
101101
</li>

phpmyfaq/assets/templates/default/login.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
<h2 class="text-center font-weight-light my-4">phpMyFAQ Login</h2>
2424
</div>
2525
<div class="card-body">
26-
<form action="{{ writeLoginPath|raw }}" method="post" accept-charset="utf-8" role="form">
27-
<input type="hidden" name="redirect-action" value="{{ action }}" />
26+
<form action="./authenticate" method="post" accept-charset="utf-8" role="form">
2827
<div class="form-floating mb-3">
2928
<input
3029
class="form-control"

phpmyfaq/assets/templates/default/twofactor.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
{% block content %}
44
<div class="col-12">
5-
{{ loginMessage }}
5+
{% if errorMessage %}
6+
<div class="alert alert-danger" role="alert">{{ errorMessage }}</div>
7+
{% endif %}
68
<div class="container py-5">
79
<div class="row">
810
<div class="col-lg-12">
@@ -13,8 +15,8 @@
1315
<h3 class="mb-0">{{ msgTwofactorEnabled }}</h3>
1416
</div>
1517
<div class="card-body">
16-
<form action="{{ writeLoginPath }}" method="post" accept-charset="utf-8" role="form" class="form">
17-
<input type="hidden" id="userid" name="userid" value="{{ userid }}">
18+
<form action="./check" method="post" accept-charset="utf-8" role="form" class="form">
19+
<input type="hidden" id="user-id" name="user-id" value="{{ userId }}">
1820
<div class="row mb-2">
1921
<label for="token">{{ msgEnterTwofactorToken }}</label>
2022
<div class="col-4 mx-auto my-2">

0 commit comments

Comments
 (0)