mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
Debugging things is fun.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -49,7 +49,7 @@ from app.dao.users_dao import (
|
||||
delete_user_verify_codes,
|
||||
get_user_by_email,
|
||||
)
|
||||
from app.enums import KeyType, NotificationStatus, NotificationType
|
||||
from app.enums import AuthType, KeyType, NotificationStatus, NotificationType
|
||||
from app.models import (
|
||||
AnnualBilling,
|
||||
Domain,
|
||||
@@ -238,7 +238,7 @@ def rebuild_ft_billing_for_day(service_id, day):
|
||||
"-a",
|
||||
"--auth_type",
|
||||
required=False,
|
||||
help="The authentication type for the user, sms_auth or email_auth. Defaults to sms_auth if not provided",
|
||||
help="The authentication type for the user, AuthType.SMS or AuthType.EMAIL. Defaults to AuthType.SMS if not provided",
|
||||
)
|
||||
@click.option(
|
||||
"-p", "--permissions", required=True, help="Comma separated list of permissions."
|
||||
@@ -703,7 +703,7 @@ def validate_mobile(ctx, param, value): # noqa
|
||||
hide_input=True,
|
||||
confirmation_prompt=True,
|
||||
)
|
||||
@click.option("-a", "--auth_type", default="sms_auth")
|
||||
@click.option("-a", "--auth_type", default=AuthType.SMS)
|
||||
@click.option("-s", "--state", default="active")
|
||||
@click.option("-d", "--admin", default=False, type=bool)
|
||||
def create_test_user(name, email, mobile_number, password, auth_type, state, admin):
|
||||
|
||||
@@ -155,7 +155,7 @@ class User(db.Model):
|
||||
|
||||
# either email auth or a mobile number must be provided
|
||||
CheckConstraint(
|
||||
"auth_type in ('email_auth', 'webauthn_auth') or mobile_number is not null"
|
||||
"auth_type in (AuthType.EMAIL, AuthType.WEBAUTHN) or mobile_number is not null"
|
||||
)
|
||||
|
||||
services = db.relationship("Service", secondary="user_to_service", backref="users")
|
||||
@@ -182,7 +182,7 @@ class User(db.Model):
|
||||
if self.platform_admin:
|
||||
return True
|
||||
|
||||
if self.auth_type == "webauthn_auth":
|
||||
if self.auth_type == AuthType.WEBAUTHN:
|
||||
return True
|
||||
|
||||
return any(
|
||||
|
||||
@@ -73,7 +73,7 @@ def handle_integrity_error(exc):
|
||||
return (
|
||||
jsonify(
|
||||
result="error",
|
||||
message="Mobile number must be set if auth_type is set to sms_auth",
|
||||
message="Mobile number must be set if auth_type is set to AuthType.SMS",
|
||||
),
|
||||
400,
|
||||
)
|
||||
|
||||
@@ -62,9 +62,10 @@ def delete_webauthn_credential(user_id, webauthn_credential_id):
|
||||
user = get_user_by_id(user_id)
|
||||
|
||||
if len(user.webauthn_credentials) == 1:
|
||||
# TODO: Only raise an error if user has auth type webauthn_auth
|
||||
# TODO: Only raise an error if user has auth type AuthType.WEBAUTHN
|
||||
raise InvalidRequest(
|
||||
"Cannot delete last remaining webauthn credential for user", status_code=400
|
||||
"Cannot delete last remaining webauthn credential for user",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
dao_delete_webauthn_credential(webauthn_credential)
|
||||
|
||||
Reference in New Issue
Block a user