MCPcopy
hub / github.com/diffgram/diffgram / new

Method new

default/methods/user/one_time_pass.py:24–46  ·  view source on GitHub ↗
(session, user)

Source from the content-addressed store, hash-verified

22
23class OneTimePass():
24 def new(session, user):
25
26
27 secret = pyotp.random_base32()
28 user.otp_secret = secret
29 user.otp_enabled = True
30
31 backup_code_list = []
32 for i in range(3):
33 backup_code = pyotp.random_base32()
34 backup_code_list.append(backup_code)
35 user.otp_backup[backup_code] = True
36
37 session.add(user)
38
39 totp = pyotp.TOTP(secret)
40 otp = totp.now()
41
42 qr_code_url = totp.provisioning_uri(
43 user.email,
44 issuer_name="Diffgram")
45
46 return otp, qr_code_url, backup_code_list
47
48
49

Callers 12

api_enable_userFunction · 0.45
enable_otp_from_webFunction · 0.45
builder_enable_coreFunction · 0.45
start_magic_login_apiFunction · 0.45
attempt_redeem_codeFunction · 0.45
user_new_coreFunction · 0.45
user_password_set_apiFunction · 0.45
start_verify_via_emailFunction · 0.45
__userscript_newFunction · 0.45
__ui_schema_newFunction · 0.45

Calls 1

addMethod · 0.45

Tested by

no test coverage detected