Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     cipher = AESCipher()
     code = cipher.encrypt(str(request.user.id)+"~|@|~"+request.user.username+"~|@|~"+request.user.email)
     url = "http://"+self.getHost(request)+reverse('account:verifyEmail', args=(code,))
     email = request.user.email
     html="""
         <!DOCTYPE html>
         <html>
         <body>
         <h3>會員 {name}:</h3>
         <p>謝謝您的註冊。</p>
         
         以下是您的驗證網址:
         <a href="{url}">點此驗證</a>
         </body>
         </html>
     """.format(url=url, name=request.user.username)
     text = "以下是你的驗證網址:\n {url}".format(url=url)
     response = {}
     smtp = SMTP()
     response['success'] = smtp.send(email, "Email 驗證", html , text) # 收件人, 標題, 內容
     return JsonResponse(response)
Ejemplo n.º 2
0
 def sendMail(self,request, user, resetCode):
     
     timeout = datetime.datetime.strftime(timezone.now()+ datetime.timedelta(hours=24), '%Y-%m-%d-%H-%M-%S')
     cipher = AESCipher()
     code = cipher.encrypt(str(user.id)+"~|@|~"+user.username+"~|@|~"+user.email+"~|@|~"+resetCode+
                           "~|@|~"+timeout )
     
     url = "http://"+self.getHost(request)+reverse('account:forgetReset', args=(code,))
     email = user.email
     html="""
         <!DOCTYPE html>
         <html>
         <body>
         <span>這是您的重置碼(分大小寫):</span><span style="background-color:#eee">{code}</span><br>
         以下是重置您密碼的網址:<br>
         <a href="{url}" target="_blank">點此重置您密碼</a>
         </body>
         </html>
     """.format(url=url, name=user.username, code = resetCode)
     text = "這是您的重置碼(分大小寫):\n {code} \n 以下是重置您密碼的網址:\n{url}".format(url=url, code = resetCode)
     smtp = SMTP()
     
     return smtp.send(email, "密碼重置", html , text) # 收件人, 標題, 內容
Ejemplo n.º 3
0
 def get(self, request, *args, **kwargs):
     kwargs['get'] = True
     kwargs['mail'] = SMTP()
     return super(Verification, self).get(request, *args, **kwargs)