Skip to content

Commit e1549a5

Browse files
committed
Remove mfa column and use mfa_secret32 instead
1 parent 0d09dbd commit e1549a5

File tree

6 files changed

+6
-11
lines changed

6 files changed

+6
-11
lines changed

doc/authen_pause.schema.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ CREATE TABLE usertable (
5656
`changed` int(11) DEFAULT NULL,
5757
changedby char(10) DEFAULT NULL,
5858
lastvisit datetime DEFAULT NULL,
59-
mfa tinyint(1) DEFAULT 0,
6059
mfa_secret32 varchar(16) DEFAULT NULL,
6160
mfa_recovery_codes text DEFAULT NULL,
6261
PRIMARY KEY (`user`),

doc/schemas/authen_pause.schema.sqlite

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ CREATE TABLE usertable (
3636
changed int(11) DEFAULT NULL,
3737
changedby char(10) DEFAULT NULL,
3838
lastvisit datetime DEFAULT NULL,
39-
mfa tinyint(1) DEFAULT 0,
4039
mfa_secret32 varchar(16) DEFAULT NULL,
4140
mfa_recovery_codes text DEFAULT NULL,
4241
PRIMARY KEY (user)

lib/pause_2017/PAUSE/Web/Controller/User/Mfa.pm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ sub edit {
4141
$pause->{error}{invalid_code} = 1;
4242
return;
4343
}
44-
my ($mfa, $secret32, $recovery_codes);
44+
my ($secret32, $recovery_codes);
4545
if ($req->param("pause99_mfa_reset")) {
46-
$mfa = 0;
4746
$secret32 = undef;
4847
$recovery_codes = undef;
4948
$c->flash(mfa_disabled => 1);
5049
} else {
51-
$mfa = 1;
5250
$secret32 = $auth->secret32;
5351
$c->flash(mfa_enabled => 1);
5452
my @codes = _generate_recovery_codes();
@@ -57,8 +55,8 @@ sub edit {
5755
}
5856
my $dbh = $mgr->authen_connect;
5957
my $tbl = $PAUSE::Config->{AUTHEN_USER_TABLE};
60-
my $sql = "UPDATE $tbl SET mfa = ?, mfa_secret32 = ?, mfa_recovery_codes = ?, changed = ?, changedby = ? WHERE user = ?";
61-
if ($dbh->do($sql, undef, $mfa, $secret32, $recovery_codes, time, $pause->{User}{userid}, $u->{userid})) {
58+
my $sql = "UPDATE $tbl SET mfa_secret32 = ?, mfa_recovery_codes = ?, changed = ?, changedby = ? WHERE user = ?";
59+
if ($dbh->do($sql, undef, $secret32, $recovery_codes, time, $pause->{User}{userid}, $u->{userid})) {
6260
my $mailblurb = $c->render_to_string("email/user/mfa/edit", format => "email");
6361
my $header = {Subject => "User update for $u->{userid}"};
6462
my @to = $u->{secretemail};

lib/pause_2017/PAUSE/Web/Plugin/WithMFAProtection.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sub register {
1616
my $u = $c->active_user_record;
1717

1818
# XXX: The active user record does not have mfa when an admin user is pretending someone else.
19-
return 1 unless $u->{mfa};
19+
return 1 unless $u->{mfa_secret32};
2020

2121
my $otp = $c->req->body_params->param('otp');
2222
if (defined $otp and $otp ne '') {

lib/pause_2017/templates/user/mfa/edit.html.ep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</div>
2323
% }
2424

25-
<h3><% if (!$pause->{HiddenUser}{mfa}) { %>Enable<% } else { %>Disable<% } %> Multifactor Authentication for <%= $pause->{HiddenUser}{userid} %>
25+
<h3><% if (!$pause->{HiddenUser}{mfa_secret32}) { %>Enable<% } else { %>Disable<% } %> Multifactor Authentication for <%= $pause->{HiddenUser}{userid} %>
2626
% if (exists $pause->{UserGroups}{admin}) {
2727
(lastvisit <%= $pause->{HiddenUser}{lastvisit} || "before 2005-12-02" %>)
2828
% }
@@ -37,7 +37,7 @@ Verification Code is invalid.
3737
</div>
3838
<hr>
3939
% }
40-
% if (!$pause->{HiddenUser}{mfa}) {
40+
% if (!$pause->{HiddenUser}{mfa_secret32}) {
4141
<div>
4242
<p>Submit 6-digit code to enable Multifactor Authentication.</p>
4343
<img src="<%= $pause->{mfa_qrcode} %>">
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
ALTER TABLE usertable ADD COLUMN mfa tinyint(1) DEFAULT 0;
21
ALTER TABLE usertable ADD COLUMN mfa_secret32 varchar(16);
32
ALTER TABLE usertable ADD COLUMN mfa_recovery_codes text;

0 commit comments

Comments
 (0)