Skip to content

Commit 9afb78a

Browse files
authored
🎨 Removes two_factor_enabled column in users db (πŸ—ƒοΈ) (#5063)
1 parent 6911102 commit 9afb78a

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""rm two_factor_enabled col in users
2+
3+
Revision ID: 0ad000429e3d
4+
Revises: 215b2cac1dbc
5+
Create Date: 2023-11-21 18:30:35.437738+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "0ad000429e3d"
13+
down_revision = "215b2cac1dbc"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.drop_column("users", "two_factor_enabled")
21+
# ### end Alembic commands ###
22+
23+
24+
def downgrade():
25+
# ### commands auto generated by Alembic - please adjust! ###
26+
op.add_column(
27+
"users",
28+
sa.Column(
29+
"two_factor_enabled",
30+
sa.BOOLEAN(),
31+
server_default=sa.text("true"),
32+
autoincrement=False,
33+
nullable=False,
34+
),
35+
)
36+
# ### end Alembic commands ###

β€Žpackages/postgres-database/src/simcore_postgres_database/models/users.pyβ€Ž

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ class UserStatus(Enum):
100100
nullable=True, # since 2FA can be configured optional
101101
doc="Confirmed user phone used e.g. to send a code for a two-factor-authentication",
102102
),
103-
sa.Column(
104-
"two_factor_enabled",
105-
sa.Boolean,
106-
server_default=sa.sql.expression.true(),
107-
nullable=False,
108-
doc="Wheter 2FA is enabled at login by this user."
109-
"NOTE that this is checked ONLY if application activates 2FA",
110-
),
111103
sa.Column("password_hash", sa.String, nullable=False),
112104
sa.Column(
113105
"primary_gid",

β€Žservices/web/server/src/simcore_service_webserver/login/handlers_auth.pyβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ async def login(request: web.Request):
9898
product=product,
9999
)
100100

101-
skip_2fa = not user.get("two_factor_enabled", True)
101+
# Some roles have login privileges
102+
skip_2fa: bool = UserRole(user["role"]) == UserRole.TESTER
102103
if skip_2fa or not settings.LOGIN_2FA_REQUIRED:
103104
return await login_granted_response(request, user=user)
104105

0 commit comments

Comments
Β (0)