diff --git a/_2fa.tpl b/_2fa.tpl index d90e171..e2bd239 100644 --- a/_2fa.tpl +++ b/_2fa.tpl @@ -15,17 +15,35 @@

2FA

-
+ % if data['secureAuth'] == True: + + - - + + -
- - -
+
+ + +
-
+ + + % else: + +
+ + + + +
+ + +
+ +
+ + %end %for type, text, animation in get('alerts', []):
diff --git a/libs/gen2fa.py b/libs/gen2fa.py new file mode 100644 index 0000000..394c937 --- /dev/null +++ b/libs/gen2fa.py @@ -0,0 +1,29 @@ +from onetimepass import valid_totp +from secrets import choice + + +def generate_secret(): # Function to return a random string with length 16. + secret = '' + while len(secret) < 16: + secret += choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567') + return secret + + +secret = generate_secret() +print('Enter the following secret in your authenticator app: ', secret) +print(""" +Instructions for saving this secret it Google Authenticator: +1. Open Google Authenticator. +2. Click plus icon at the right bottom. +3. Click Enter a setup key. +4. Enter an Account name of your choice and enter the secret provided above. +5. Click Add. +""") +while True: + otp = int(input('Please enter the otp generated by your authenticator app: ')) + authenticated = valid_totp(otp, secret) + if authenticated: + print('Correct otp, Authenticated!') + elif not authenticated: + print('Wrong otp, please try again.') + diff --git a/user.tpl b/user.tpl index 63fdc09..9737fa8 100644 --- a/user.tpl +++ b/user.tpl @@ -50,34 +50,22 @@ - - +
- {{"" if data['secureAuth'] == True else ""}} - + % if data['secureAuth'] == True: + + % else: + + %end