Ejemplo n.º 1
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))
Ejemplo 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)
        realname=self.get_argument("realname",None) 
        
        user = User()
        user.mobile = mobile
	user.realname = realname
        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("请确认新密码和重复密码一致")
		elif len(realname) > 32:
		    self.flash("微信账号超出长度限制")
		elif len(realname) < 2:
		    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()
       			user.updatesignin()
                        self.session['user'] = user
                 
                        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()
                        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")
                        url="/signup?sharer="+user.mobile
            		self.redirect(url,permanent=True)
			return
                    #else:
                    #    self.flash("请输入正确的验证码")
            else:
                self.flash("请输入密码和确认密码")
        except Exception, ex:
            self.flash(str(ex))
Ejemplo n.º 3
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))
Ejemplo n.º 4
0
 def get(self):
     next_url = self.get_cookie("next", "/")
     
     if 'oauth' in self.session:
         oauth = self.session['oauth']
         
         try:
             oauth = Oauth.get(Oauth.src == oauth['src'],  Oauth.openid == oauth['id'])
             user = User.get(User.id == oauth.uid)
             
             del self.session["oauth"]
             self.session['user'] = user
             self.session.save()
             self.redirect(next_url)
             return
         except:
             pass
         
         self.render('site/oauth.html', oauth = oauth, next = next_url)
Ejemplo n.º 5
0
    def get(self):
        next_url = self.get_cookie("next", "/")

        if 'oauth' in self.session:
            oauth = self.session['oauth']

            try:
                oauth = Oauth.get(Oauth.src == oauth['src'],
                                  Oauth.openid == oauth['id'])
                user = User.get(User.id == oauth.uid)

                del self.session["oauth"]
                self.session['user'] = user
                self.session.save()
                self.redirect(next_url)
                return
            except:
                pass

            self.render('site/oauth.html', oauth=oauth, next=next_url)
Ejemplo 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)

        if mobile and password:
            try:
                user = User.get(User.mobile == mobile)

                if user.check_password(password):
                    if user.group > 0:
                        user.updatesignin()

                        self.session['user'] = user

                        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()
                        if mobile != "root":
                            self.redirect(self.next_url)
                        else:
                            self.redirect("/admin")
                        return
                    else:
                        self.flash("此账户被禁止登录,请联系管理员。")
                else:
                    self.flash("密码错误")
            except Exception, ex:
                logging.error(ex)
                self.flash("此用户不存在")
Ejemplo n.º 7
0
    def post(self):
        if self.get_current_user():
            self.redirect("/")
            return
        
        mobile = self.get_argument("mobile", None)
        password = self.get_argument("password", None)

        if mobile and password:
            try:
                user = User.get(User.mobile == mobile)
                
                if user.check_password(password):
                    if user.group > 0:
                        user.updatesignin()

                        self.session['user'] = user
                        
                        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()

                        self.redirect(self.next_url)

                        return
                    else:
                        self.flash("此账户被禁止登录,请联系管理员。")
                else:
                    self.flash("密码错误")
            except Exception as ex:
                logging.error(ex)
                self.flash("此用户不存在")
        else:
            self.flash("请输入用户名或者密码")
        
        self.render("site/signin.html", next = self.next_url)
Ejemplo n.º 8
0
    def post(self):
        mobile = self.get_argument("mobile", None)
        password = self.get_argument("password", None)
        if self.get_current_user():
            if mobile != "root":
		self.redirect("/")
	    else:
		self.redirect("/admin/users")
            return    
        if mobile and password:
            try:
                user = User.get(User.mobile == mobile)
                
                if user.check_password(password):
                    if user.group > 0:
                        user.updatesignin()
                        
                        self.session['user'] = user
                        
                        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()
			if mobile != "root":
                        	url="/signup?sharer="+user.mobile
            			self.redirect(url,permanent=True)
			else:
				self.redirect("/admin/users")
		        return
                    else:
                        self.flash("此账户被禁止登录,请联系管理员。")
                else:
                    self.flash("密码错误")
            except Exception, ex:
                logging.error(ex)
                self.flash("此用户不存在")
Ejemplo n.º 9
0
    def post(self):
        if self.get_current_user():
            self.redirect("/")
            return

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

        if mobile and password:
            try:
                logging.warning('sssssssssssssssssss')
                user = User.get(User.mobile == mobile)
                logging.warning('sssssssssssssssssss1111')
                if user.check_password(password):
                    logging.warning('sssssssssssssssssss2222')
                    if user.group > 0:
                        logging.warning('sssssssssssssssssss3333')
                        user.updatesignin()

                        self.session['user'] = user

                        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']
                        logging.warning(dict(self.session.items()))
                        self.session.save()

                        self.redirect(self.next_url)
                        return
                    else:
                        self.flash("此账户被禁止登录,请联系管理员。")
                else:
                    self.flash("密码错误")
            except Exception, ex:
                var = traceback.format_exc()
                logging.error(var)
                self.flash("此用户不存在")
Ejemplo n.º 10
0
                        self.application.session_store.set_session(str(mobile)+':'+str(password), {}, None, expiry=24*60*60)

                        x = args["x"]
                        y = args["y"]
                        province = args["province"]
                        city = args["city"]
                        region = args["region"]
                        address = args["address"]
                        if x and y:
                            User_Login_Log.create(user=user.id, x=x, y=y, province=province, city=city, region=region, address=address, created=int(time.time()))
                    else:
                        result['msg'] ="此账户被禁止登录,请联系管理员。"
                else:
                    result['msg'] ="密码错误"
            except Exception, ex:
                oauths = Oauth.select().where(Oauth.openid == mobile)
                if oauths.count() > 0:
                    user = oauths[0].user
                    if user.check_mobile_password(password):
                        if user.isactive > 0:
                            user.updatesignin()
                            result['flag'] = 1
                            result['msg'] = {'username': user.username,
                                             'nickname': user.nickname,
                                             'mobile': user.mobile,
                                             'score': user.score,
                                             'balance': user.balance,
                                             'id': user.id,
                                             'bindmobile': user.bindmobile(),
                                             'hascheckedin': user.hascheckedin()}
                            self.application.session_store.set_session(str(mobile)+':'+str(password), {}, None, expiry=24*60*60)