Exemplo n.º 1
0
 def get(self):
     result = {'status':False, 'msg':''}
     mobile = self.get_argument("mobile", None)
     
     UserVcode.delete().where(UserVcode.created < (int(time.time()) - 2 * 3600)).execute()
     
     uservcode = UserVcode()
     uservcode.mobile = mobile
     uservcode.vcode = random.randint(1000, 9999)
     
     try:
         uservcode.validate()
         
         if UserVcode.select().where(UserVcode.mobile == mobile).count() > 3:
             result['msg'] = 503
         else:
             try:
                 sendmsg(self.settings, mobile, "您在菜市优品获取的验证码为" + str(uservcode.vcode) + "【菜市优品】")
                 uservcode.save()
                 
                 logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))
                 
                 result['status'] = True
                 result['msg'] = uservcode.vcode
             except Exception, ex:
                 logging.error(ex)
                 result['msg'] = 500
         
     except Exception, ex:
         logging.error(ex)
         result['msg'] = 400
Exemplo n.º 2
0
    def post(self):
        if self.get_current_user():
            self.redirect("/")
            return

        mobile = self.get_argument("mobile", None)
        password = self.get_argument("password", None)
        apassword = self.get_argument("apassword", None)
        vcode = self.get_argument("vcode", None)
        sharer = self.get_argument("sharer", None)
        openid = self.get_argument("openid", None)

        user = User()
        user.mobile = mobile
        user.openid = openid
        print openid
        user.password = User.create_password(password)

        try:
            user.validate()

            if password and apassword:
                if len(password) < 6:
                    self.flash("请确认输入6位以上新密码")
                elif password != apassword:
                    self.flash("请确认新密码和重复密码一致")
                else:
                    if UserVcode.select().where(
                        (UserVcode.mobile == mobile)
                            & (UserVcode.vcode == vcode)).count() > 0:
                        UserVcode.delete().where(
                            (UserVcode.mobile == mobile)
                            & (UserVcode.vcode == vcode)).execute()
                        user.save()

                        if 'oauth' in self.session:
                            oauth = self.session['oauth']
                            o = Oauth()
                            o.uid = user.id
                            o.openid = oauth['id']
                            o.src = oauth['src']
                            o.save()

                            del self.session['oauth']
                            self.session.save()
                        print sharer
                        User.update(credit=User.credit +
                                    1).where(User.mobile == mobile).execute()
                        #if sharer != None
                        User.update(credit=User.credit +
                                    1).where(User.mobile == sharer).execute()
                        self.flash("注册成功,请先登录。", "ok")
                        self.redirect("/signin")
                        return
                    else:
                        self.flash("请输入正确的验证码")
            else:
                self.flash("请输入密码和确认密码")
        except Exception, ex:
            self.flash(str(ex))
Exemplo n.º 3
0
    def get(self):
        result = {'status':False, 'msg':''}
        mobile = self.get_argument("mobile", None)
        
        UserVcode.delete().where(UserVcode.created < (int(time.time()) - 2 * 3600)).execute()
        
        uservcode = UserVcode()
        uservcode.mobile = mobile
        uservcode.vcode = random.randint(1000, 9999)
        
        try:
            uservcode.validate()
            
            if UserVcode.select().where(UserVcode.mobile == mobile).count() > 3:
                result['msg'] = 503
            else:
                try:
                    sendmsg(self.settings, mobile, "验证码:{0}【华图科技】".format(str(uservcode.vcode)))
                    uservcode.save()
                    
                    logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))
                    
                    result['status'] = True
                    result['msg'] = uservcode.vcode
                except Exception as ex:
                    logging.error(ex)
                    result['msg'] = 500
            
        except Exception as ex:
            logging.error(ex)
            result['msg'] = 400
 
        self.write(simplejson.dumps(result))
Exemplo n.º 4
0
    def post(self):
        if self.get_current_user():
            self.redirect("/")
            return
        
        mobile = self.get_argument("mobile", None)
        password = self.get_argument("password", None)
        apassword = self.get_argument("apassword", None)
        vcode = self.get_argument("vcode", None)
        sharer = self.get_argument("sharer", None)
        openid = self.get_argument("openid", None) 
        
        user = User()
        user.mobile = mobile
        user.openid = openid
        print openid
        user.password = User.create_password(password)
        
        try:
            user.validate()
            
            if password and apassword:
                if len(password) < 6:
                    self.flash("请确认输入6位以上新密码")
                elif password != apassword:
                    self.flash("请确认新密码和重复密码一致")
                else:
                    if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
                        UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
                        user.save()
                        
                        if 'oauth' in self.session:
                            oauth = self.session['oauth']
                            o = Oauth()
                            o.uid = user.id
                            o.openid = oauth['id']
                            o.src = oauth['src']
                            o.save()
                            
                            del self.session['oauth']
                            self.session.save()
                        print sharer
			User.update(credit = User.credit + 1).where(User.mobile == mobile).execute()
                        #if sharer != None
                        User.update(credit = User.credit + 1).where(User.mobile == sharer).execute()
			self.flash("注册成功,请先登录。", "ok")
                        self.redirect("/signin")
                        return
                    else:
                        self.flash("请输入正确的验证码")
            else:
                self.flash("请输入密码和确认密码")
        except Exception, ex:
            self.flash(str(ex))
Exemplo n.º 5
0
    def post(self):
        if self.get_current_user():
            self.redirect("/")
            return

        mobile = self.get_argument("mobile", None)
        password = self.get_argument("password", None)
        apassword = self.get_argument("apassword", None)
        vcode = self.get_argument("vcode", None)

        try:
            user = User().get(mobile=mobile)
        except:
            self.flash("此用户不存在")
            self.redirect("/resetpassword")
            return

        try:
            if password and apassword:
                if len(password) < 6:
                    self.flash("请确认输入6位以上新密码")
                elif password != apassword:
                    self.flash("请确认新密码和重复密码一致")
                else:
                    if UserVcode.select().where(
                        (UserVcode.mobile == mobile)
                            & (UserVcode.vcode == vcode)).count() > 0:
                        UserVcode.delete().where(
                            (UserVcode.mobile == mobile)
                            & (UserVcode.vcode == vcode)).execute()
                        user.password = User.create_password(password)
                        user.save()
                        self.flash("重置密码成功,请先登录。", "ok")
                        self.redirect("/signin")
                        return
                    else:
                        self.flash("请输入正确的验证码")
            else:
                self.flash("请输入密码和确认密码")
        except Exception, ex:
            self.flash(str(ex))
Exemplo n.º 6
0
 def post(self):
     if self.get_current_user():
         self.redirect("/")
         return
     
     mobile = self.get_argument("mobile", None)
     password = self.get_argument("password", None)
     apassword = self.get_argument("apassword", None)
     vcode = self.get_argument("vcode", None)
     
     try:
         user = User().get(mobile = mobile)
     except:
         self.flash("此用户不存在")
         self.redirect("/resetpassword")
         return
     
     try:
         if password and apassword:
             if len(password) < 6:
                 self.flash("请确认输入6位以上新密码")
             elif password != apassword:
                 self.flash("请确认新密码和重复密码一致")
             else:
                 if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
                     UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
                     user.password = User.create_password(password)
                     user.save()
                     self.flash("重置密码成功,请先登录。", "ok")
                     self.redirect("/signin")
                     return
                 else:
                     self.flash("请输入正确的验证码")
         else:
             self.flash("请输入密码和确认密码")
     except Exception as ex:
         self.flash(str(ex))
     
     self.render("site/resetpassword.html")
Exemplo n.º 7
0
    def get(self):
        result = {'status': False, 'msg': ''}
        mobile = self.get_argument("mobile", None)

        UserVcode.delete().where(
            UserVcode.created < (int(time.time()) - 2 * 3600)).execute()

        uservcode = UserVcode()
        uservcode.mobile = mobile
        uservcode.vcode = random.randint(1000, 9999)

        try:
            uservcode.validate()

            if UserVcode.select().where(
                    UserVcode.mobile == mobile).count() > 3:
                result['msg'] = 503
            else:
                try:
                    sendmsg(self.settings, mobile,
                            "您在菜市优品获取的验证码为" + str(uservcode.vcode) + "【菜市优品】")
                    uservcode.save()

                    logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))

                    result['status'] = True
                    result['msg'] = uservcode.vcode
                except Exception, ex:
                    logging.error(ex)
                    result['msg'] = 500

        except Exception, ex:
            logging.error(ex)
            result['msg'] = 400