def emailRegistration(self, recipient, token): logger.debug("emailRegistration()") CONFIG_GROUP_ADMIN = get_udp_ns_fieldname(CONFIG_ADMIN) app_title = session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_name"] activation_link = url_for( "dealer_views_bp.dealer_registration_state_get", stateToken=token, _external=True, _scheme=session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"]) subject = "Welcome to the {app_title}".format(app_title=session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_name"]) # Send Activation Email to the user message = """ Welcome to the {app_title}! Click this link to activate your account <br /> <a href='{activation_link}'>{activation_link}</a>). """.format(app_title=app_title, activation_link=activation_link) Email.send_mail(subject=subject, message=message, recipients=[recipient]) # Send Activation Email to the Admin subject_admin = "Registration Activation request for user {user}".format(user=request.form.get('email')) message_admin = """ A new user has registered. His request is awaiting your approval. Click this link to log into your account <br /> <a href='{activation_link}'>{activation_link}</a> to review the request """.format( activation_link=url_for( "dealer_views_bp.workflow_approvals_get", _external=True, _scheme=session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"])) return self.emailAllMembersOfGroup(group_name=CONFIG_GROUP_ADMIN, subject=subject_admin, message=message_admin)
def ecommerce_emailWorkFlowRequest(group_id): logger.debug("emailWorkFlowRequest()") okta_admin = OktaAdmin(session[SESSION_INSTANCE_SETTINGS_KEY]) activation_link = url_for( "ecommerce_views_bp.ecommerce_approvals_get", _external=True, _scheme=session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"]) # Send Activation Email to the Admin subject_admin = "A workflow request was received" message_admin = """\ <p><h1>A new request for access was received.</h1><br> The request is awaiting your approval.<br><br> Click this link to log into your account and review the request<br><br> <a href='{activation_link}'>{activation_link}</a> </p> """.format(activation_link=activation_link) # Find All members that will be notified recipients = [] user_list = okta_admin.get_user_list_by_group_id(group_id) for user in user_list: recipients.append({"address": user["profile"]["email"]}) if recipients: email_send = Email.send_mail(subject=subject_admin, message=message_admin, recipients=recipients) return email_send else: return ''
def emailLogin(recipient, username): logger.debug("emailRegistration()") subject = "Your Username was Found" message = """ You have requested to retrieve your username. <br /><br /><br />Your Username is: {username} <br /><br /><br />If you did not request to retrieve your username, please contact us at your earliest convenience. """.format(username=username) test = Email.send_mail(subject=subject, message=message, recipients=recipient) logger.debug(test)
def ecommerce_email_registration(recipient, token): logger.debug("ecommerce_email_registration()") app_title = session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_name"] activation_link = url_for( "gbac_registration_bp.gbac_registration_state_get", stateToken=token, _external=True, _scheme=session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"]) subject = "Welcome to the {app_title}".format(app_title=session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_name"]) message = """ Thank you for Applying for {app_title}! <br /> <br />Click this link to activate your account. <br /><br /> <a href='{activation_link}'>Click Here to Activate Account</a> """.format(app_title=app_title, activation_link=activation_link) test = Email.send_mail(subject=subject, message=message, recipients=[recipient]) logger.debug(test)
def emailAllMembersOfGroup(self, group_name, subject, message): logger.debug("emailAllMembersOfGroup()") okta_admin = OktaAdmin(session[SESSION_INSTANCE_SETTINGS_KEY]) # Find the Admin Group group_list = okta_admin.get_groups_by_name(group_name) for group in group_list: if group["profile"]["name"] == group_name: group_id = group["id"] # Find All members that will be notified recipients = [] user_list = okta_admin.get_user_list_by_group_id(group_id) for user in user_list: recipients.append({"address": user["profile"]["email"]}) if recipients: email_send = Email.send_mail(subject=subject, message=message, recipients=recipients) return email_send