fix email field bug, update examples

This commit is contained in:
KF7EEL 2021-09-01 13:52:55 -07:00
parent 2a556d5b9b
commit 87bb1aa6d1
2 changed files with 17 additions and 12 deletions

View File

@ -121,7 +121,7 @@ EXTRA_2: DmR4
# Secret used to authenticate with user managment server, before checking if user login is approved # Secret used to authenticate with user managment server, before checking if user login is approved
SHARED_SECRET: test SHARED_SECRET: test
# Shorten passphrases # Shorten passphrases
SHORTEN_PASSPHRASE: False SHORTEN_PASSPHRASE: True
SHORTEN_SAMPLE: 4 SHORTEN_SAMPLE: 4
SHORTEN_LENGTH: 4 SHORTEN_LENGTH: 4
BURN_FILE: ./burn_ids.txt BURN_FILE: ./burn_ids.txt

View File

@ -607,6 +607,7 @@ def create_app():
def _after_user_registered_hook(sender, user, **extra): def _after_user_registered_hook(sender, user, **extra):
edit_user = User.query.filter(User.username == user.username).first() edit_user = User.query.filter(User.username == user.username).first()
radioid_data = ast.literal_eval(get_ids(user.username)) radioid_data = ast.literal_eval(get_ids(user.username))
## edit_user.notes = ''
edit_user.dmr_ids = str(radioid_data[0]) edit_user.dmr_ids = str(radioid_data[0])
edit_user.first_name = str(radioid_data[1]) edit_user.first_name = str(radioid_data[1])
edit_user.last_name = str(radioid_data[2]) edit_user.last_name = str(radioid_data[2])
@ -1131,12 +1132,15 @@ def create_app():
edit_user.initial_admin_approved = True edit_user.initial_admin_approved = True
db.session.commit() db.session.commit()
email_text = Misc.query.filter_by(field_1='approval_email').first() email_text = Misc.query.filter_by(field_1='approval_email').first()
try:
msg = Message(recipients=[edit_user.email], msg = Message(recipients=[edit_user.email],
sender=(title, MAIL_DEFAULT_SENDER), sender=(title, MAIL_DEFAULT_SENDER),
subject='Account Approval', subject='Account Approval',
body = str(email_text.field_2)) body = str(email_text.field_2))
mail.send(msg) mail.send(msg)
content = '''<p style="text-align: center;">User approved: <strong>''' + str(request.args.get('callsign')) + '''</strong></p>\n''' except:
content = 'Failed to send email. Approved user anyway'
content = content + '''<p style="text-align: center;">User approved: <strong>''' + str(request.args.get('callsign')) + '''</strong></p>\n'''
elif request.method == 'GET' and request.args.get('callsign') and request.args.get('email_verified') == 'true': elif request.method == 'GET' and request.args.get('callsign') and request.args.get('email_verified') == 'true':
edit_user = User.query.filter(User.username == request.args.get('callsign')).first() edit_user = User.query.filter(User.username == request.args.get('callsign')).first()
@ -1150,8 +1154,9 @@ def create_app():
if request.form.get('callsign'): if request.form.get('callsign'):
callsign = request.form.get('callsign') callsign = request.form.get('callsign')
u = User.query.filter_by(username=callsign).first() u = User.query.filter_by(username=callsign).first()
if u.notes == None: user_email_address = 'None'
user_notes = '' if str(u.email):
user_email_address = str(u.email)
confirm_link = '' confirm_link = ''
if u.email_confirmed_at == None: if u.email_confirmed_at == None:
confirm_link = '''<p style="text-align: center;"><a href="''' + url + '/edit_user?email_verified=true&callsign=' + str(u.username) + '''"><strong>Verify email - <strong>''' + str(u.username) + '''</strong></strong></a></p>\n''' confirm_link = '''<p style="text-align: center;"><a href="''' + url + '/edit_user?email_verified=true&callsign=' + str(u.username) + '''"><strong>Verify email - <strong>''' + str(u.username) + '''</strong></strong></a></p>\n'''
@ -1171,7 +1176,7 @@ def create_app():
<td style="text-align: center;"><strong>Passphrase</strong></td> <td style="text-align: center;"><strong>Passphrase</strong></td>
</tr> ''' </tr> '''
for i in id_dict.items(): for i in id_dict.items():
print(i[1]) ## print(i[1])
if isinstance(i[1], int) == True: if isinstance(i[1], int) == True:
passphrase_list = passphrase_list + ''' passphrase_list = passphrase_list + '''
<tr> <tr>
@ -1260,7 +1265,7 @@ def create_app():
<tr style="height: 51.1667px;"> <tr style="height: 51.1667px;">
<td style="height: 51.1667px; text-align: center;"> <td style="height: 51.1667px; text-align: center;">
<label for="username">Portal Email:</label><br> <label for="username">Portal Email:</label><br>
<input type="text" id="email" name="email" value="''' + u.email + '''"><br> <input type="text" id="email" name="email" value="''' + user_email_address + '''"><br>
</td></tr> </td></tr>
<tr style="height: 51.1667px;"> <tr style="height: 51.1667px;">
@ -1283,7 +1288,7 @@ def create_app():
<tr style="height: 51.1667px;"> <tr style="height: 51.1667px;">
<td style="height: 51.1667px; text-align: center;"> <td style="height: 51.1667px; text-align: center;">
<label for="message">Notes<br /></label></strong><br /><textarea cols="40" name="notes" rows="5" >''' + str(user_notes) + '''</textarea><br /><br /> <label for="message">Notes<br /></label></strong><br /><textarea cols="40" name="notes" rows="5" >''' + str(u.notes) + '''</textarea><br /><br />
</td></tr> </td></tr>