Esempio n. 1
0
def register_from_email(T, args):
    c = T.conn.cursor()
    c.execute("select body from messages where messageid=%s", (args["messageid"],))
    for (body,) in c.fetchall():
        msg = email.message_from_string(body)
        sender = msg["from"]
        (full_name, email_address) = email.utils.parseaddr(sender)
        hashcode = dbmaint.user_hash(T.conn, userid=dbmaint.user_register(T.conn, email_address))
        response = (
            template2.replace("%TO%", sender)
            .replace("%FROM%", FROM_ADDRESS)
            .replace("%EMAIL_ADDRESS%", email_address)
            .replace("%HASH%", hashcode)
        )
        args["messageid"] = T.insert_email_message(tester.EMAIL_TAG_AUTOMATED_RESPONSE, response)
        T.insert_task(tester.TASK_CRYPTO_MESSAGE, args)
        T.commit()
        return True
Esempio n. 2
0
 def login(self,email,userhash):
     if userhash != dbmaint.user_hash(self.conn,email=email):
         print("Invalid hash for {}".format(email))
         exit(0)
     self.email  = email
     self.userid = dbmaint.user_lookup(self.conn,email)