Example #1
0
 def get(self):
     result = UserOperate().get_user(self.ags['username'])
     if result is not None:
         username = AesUtil().decypt(self.ags['token']).replace(str(result['password']), '')
         if username == self.ags['username']:
             return {'status': True}
         return {'status': False}
     else:
         return {'status': False}
Example #2
0
 def post(self):
     result = UserOperate().get_user(self.ags['username'])
     if result is not None and self.ags['password'] == str(
             result['password']):
         return {
             'login':
             True,
             'token':
             AesUtil().encypt(
                 str(result['user']) + str(result['password']))
         }, 200
     else:
         return {'login': False, 'token': None}, 200
Example #3
0
 def send(self, to_receiver, subject, body):
     # 设置邮件正文,这里是支持HTML的
     msg = MIMEText(body, 'html')
     # 设置正文为符合邮件格式的HTML内容
     msg['subject'] = subject
     # 设置邮件标题
     msg['from'] = self.sender
     # 设置发送人
     msg['to'] = ",".join(to_receiver)
     try:
         send = smtplib.SMTP_SSL(self.mail_host, self.port)
         # 注意!如果是使用SSL端口,这里就要改为SMTP_SSL
         send.login(self.mail_user, AesUtil().decypt(self.mail_password))
         # 登陆邮箱
         send.sendmail(self.sender, self.receivers, msg.as_string())
         # 发送邮件!
         logging.info('Done.sent email success')
     except smtplib.SMTPException as e:
         logging.error('Error.sent email fail' + str(e))
Example #4
0
 def post(self):
     result = {"message": None}
     if (self.ags['aes'] is not None):
         result = AesUtil().aes(self.ags['aes'])
     return result