MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / mfa_add

Function mfa_add

web/pgadmin/authenticate/mfa/utils.py:359–385  ·  view source on GitHub ↗

A utility funtion to add/update the auth method in the configuration database for the current user with the method specific options. e.g. email-address for 'email' method, and 'secret' for the 'authenticator' Args: auth_name (str): Name of the auth method options (

(auth_name: str, options: str)

Source from the content-addressed store, hash-verified

357
358
359def mfa_add(auth_name: str, options: str) -> None:
360 """
361 A utility funtion to add/update the auth method in the configuration
362 database for the current user with the method specific options.
363
364 e.g. email-address for 'email' method, and 'secret' for the 'authenticator'
365
366 Args:
367 auth_name (str): Name of the auth method
368 options (str) : A data options specific to the auth method
369 """
370 auth = UserMFA.query.filter_by(
371 user_id=current_user.id, mfa_auth=auth_name
372 ).first()
373
374 if auth is None:
375 auth = UserMFA(
376 user_id=current_user.id,
377 mfa_auth=auth_name,
378 options=options
379 )
380 db.session.add(auth)
381
382 # We will override the existing options
383 auth.options = options
384
385 db.session.commit()
386
387
388def fetch_auth_option(auth_name: str) -> (str, bool):

Callers 2

registration_viewMethod · 0.85
registration_viewMethod · 0.85

Calls 3

UserMFAClass · 0.90
firstMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected