include password in welcome email

This commit is contained in:
Max Erenberg 2021-08-23 23:36:49 +00:00
parent 08a3faaefc
commit e851c77e74
5 changed files with 16 additions and 8 deletions

View File

@ -11,8 +11,11 @@ class IMailService(Interface):
def send(_from: str, to: str, headers: Dict[str, str], content: str):
"""Send a message with the given headers and content."""
def send_welcome_message_to(user: IUser):
"""Send a welcome message to the new member."""
def send_welcome_message_to(user: IUser, password: str):
"""
Send a welcome message to the new member, including their temporary
password.
"""
def announce_new_user(user: IUser, operations: List[str]):
"""

View File

@ -51,11 +51,11 @@ class MailService:
client.send_message(msg)
client.quit()
def send_welcome_message_to(self, user: IUser):
def send_welcome_message_to(self, user: IUser, password: str):
template = self.jinja_env.get_template('welcome_message.j2')
# TODO: store surname and givenName in LDAP
first_name = user.cn.split(' ', 1)[0]
body = template.render(name=first_name, user=user.uid)
body = template.render(name=first_name, user=user.uid, password=password)
self.send(
f'Computer Science Club <exec@{self.base_domain}>',
f'{user.cn} <{user.uid}@{self.base_domain}>',

View File

@ -2,7 +2,6 @@ Hello {{ name }}:
Welcome to the Computer Science Club! We are pleased that you have chosen to join us. We welcome you to come out to our events, or just hang out in our office (MC 3036/3037). You have been automatically subscribed to our mailing list, csc-general, which we use to keep you informed of upcoming events.
Typical events include:
* Talks: these mostly technical talks are given by members, faculty and distinguished guests. Past topics include randomized algorithms, video encoding, computer security and adaptable user interfaces. People of all skill levels are welcome, and snacks are often served after talks.
* Code parties: late-night hackathons perfect for contributing to open source, working on personal projects, or making progress on a CS assignment you've been putting off. Refreshments provided, and both music and geek classic movies have been played in the past.
@ -19,7 +18,13 @@ You can hear about upcoming events in a number of ways:
Even when events aren't being held, you are welcome to hang out in the club office (MC 3036/3037, across the hall from MathSoc). It's often open late into the evening, and sells pop and snacks at reasonable prices. If you're so inclined, you are also welcome in our IRC channel, #csc on FreeNode.
You now have a CSC user account with username "{{ user }}" and the password you supplied when you joined. You can use this account to log into almost any CSC system, including our office terminals and servers. A complete list is available at:
You now have a CSC user account with username "{{ user }}". Your temporary password is:
{{ password }}
You will be prompted to change your password when you login to any CSC machine for the first time.
You can use this account to log into almost any CSC system, including our office terminals and servers. A complete list is available at:
http://wiki.csclub.uwaterloo.ca/Machine_List

View File

@ -84,7 +84,7 @@ class AddMemberTransaction(AbstractTransaction):
# user has already seen the email
try:
self.mail_srv.send_welcome_message_to(user)
self.mail_srv.send_welcome_message_to(user, password)
yield 'send_welcome_message'
except Exception as err:
logger.warning('send_welcome_message failed:\n' + traceback.format_exc())

View File

@ -1,7 +1,7 @@
def test_welcome_message(cfg, mock_mail_server, mail_srv, simple_user):
base_domain = cfg.get('base_domain')
mock_mail_server.messages.clear()
mail_srv.send_welcome_message_to(simple_user)
mail_srv.send_welcome_message_to(simple_user, 'password')
msg = mock_mail_server.messages[0]
assert msg['from'] == f'exec@{base_domain}'
assert msg['to'] == f'{simple_user.uid}@{base_domain}'