当前位置: 首页>>代码示例>>Python>>正文


Python User.code方法代码示例

本文整理汇总了Python中db.User.code方法的典型用法代码示例。如果您正苦于以下问题:Python User.code方法的具体用法?Python User.code怎么用?Python User.code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.User的用法示例。


在下文中一共展示了User.code方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_post

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import code [as 别名]
 def on_post(self, req, resp):
     doc = req.context['doc']
     users=Session.query(User).all()
     unique=True
     for user in users:
         if doc['email'] == user.email:
             unique=False
     if unique:
         user = User(name=doc['name'], email=doc['email'].lower(), signedin=False,registerTime=datetime.datetime.today())
         print(datetime.datetime.today())
         user.salt = bcrypt.gensalt()
         user.pw_hash = bcrypt.hashpw(doc['password'].encode('utf-8'), user.salt)
         s=smtplib.SMTP_SSL('smtp.gmail.com',465)
         s.ehlo()
         s.login('[email protected]','[email protected]')
         code=randint(1000000,10000000)
         user.code=code
         msg=MIMEText('Hi '+user.name+', your verification URL is: '+'http://192.168.1.127:8000/confirmation/'+str(code))
         msg['From']='[email protected]'
         msg['To']=user.email
         msg['Subject']='PhoenixNow Account Confirmation'
         s.send_message(msg)
         s.close()
         Session.add(user)
         Session.flush()
         Session.commit()
         req.context['user'] = user.id
         req.context['result'] = {"result": "success", "action": "register"}
     else:
         user=get_user(req,resp)
         td=datetime.timedelta(minutes=30)
         if datetime.datetime.today()-td<user.registerTime or user.emailVerified==True:
             description = "User was already made"
             title = "User creation conflict"
             raise falcon.HTTPConflict(title=title, description=description)
         else:
             Session.delete(user)
             Session.flush()
             user = User(name=doc['name'], email=doc['email'], signedin=False,registerTime=datetime.datetime.today())
             print(datetime.datetime.today())
             user.salt = bcrypt.gensalt()
             user.pw_hash = bcrypt.hashpw(doc['password'].encode('utf-8'), user.salt)
             s=smtplib.SMTP_SSL('smtp.gmail.com',465)
             s.ehlo()
             s.login('[email protected]','[email protected]')
             code=randint(1000000,10000000)
             user.code=code
             msg=MIMEText('Hi '+user.name+', your verification URL is: '+'http://192.168.1.127:8000/confirmation/'+str(code))
             msg['From']='[email protected]'
             msg['To']=user.email
             msg['Subject']='PhoenixNow Account Confirmation'
             s.send_message(msg)
             s.close()
             Session.add(user)
             Session.flush()
             Session.commit()
             req.context['user'] = user.id
             req.context['result'] = {"result": "success", "action": "register"}
开发者ID:ECGHelloWorld,项目名称:PhoenixNowBackend,代码行数:60,代码来源:users.py


注:本文中的db.User.code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。