def get(self, idencode):

        
        params = {}
        params[KEY.IDENCODE] = idencode

        #先判段是是否有人确认过了
        verify_user_info = db.get_user_verify_info(params)
        if verify_user_info is None:
            return self.write('the link is fail')

        #没有的话 清除数据
        db.clear_verify_user_info(verify_user_info)

        #判段时间是否失效

        s = verify_user_info[KEY.TIME]
        emailTime = time.mktime(s.timetuple())
        nowTime = time.time()
        timeInterval = nowTime - emailTime

        verify_user_info[KEY.EMAIL] = verify_user_info[KEY.EMAIL].replace("%40", "@")
        if timeInterval > 86400:
            sendEmail.sendEmail([verify_user_info[KEY.EMAIL]], "认证失败消息", "您的实名认证失败,请重新认证")
            return self.write('the link is fail (The effective time has passed.)')
        else:
            verify_user_info[KEY.IS_VERIFY] = 1

            success = db.update_user(verify_user_info)
            if success:
                return self.write("success comfirm")
            else:
                sendEmail.sendEmail([verify_user_info[KEY.EMAIL]], "认证失败消息", "您的实名认证失败,请重新认证")
                return self.write("server error")
Exemplo n.º 2
0
    def get(self):

        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        verify_user_info = db.get_user_verify_info(params)

        if verify_user_info is None:
            return self.render("real-nameComfirm.html", id=id)
        else:
            return self.render("comfirm-submit.html", id=id)
    def get(self):

        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        verify_user_info = db.get_user_verify_info(params)

        if verify_user_info is None:
            return self.render("real-nameComfirm.html", id = id)
        else:
            return self.render("comfirm-submit.html", id = id)
Exemplo n.º 4
0
    def post(self):

        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)
        #加入邮件
        params[KEY.EMAIL] = user[KEY.EMAIL]
        #对图片名称加密
        md5_encode = hashlib.md5()
        md5_encode.update(str(id))
        saveName = md5_encode.hexdigest()

        #saveName = id
        nowpath = os.path.dirname(__file__).replace("handler", "static")
        path = os.path.join(nowpath, "images", "head")
        filepath = uploadImageUtils.uploadImageUtils(self.request, "fileImage",
                                                     saveName, path)

        if filepath:
            params[KEY.NAME] = self.get_argument('realname')

            params[KEY.IDENTITY_ID] = self.get_argument('realID')
            #-----------------------------------------------------
            params[KEY.AVATAR] = saveName + filepath[-4:]

            #防止有人跨过登录这个地址
            while (True):

                idencode = ''.join(random.sample(string.ascii_letters, 4))
                tempParams = {}
                tempParams[KEY.IDENCODE] = idencode
                if db.get_user_verify_info(tempParams) == None:
                    params[KEY.IDENCODE] = idencode
                    break

            verify = db.add_user_verify(params)

            if verify != -1:

                link = "http://120.24.208.130:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                # link = "http://localhost:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                if sendEmail.sendEmailForVerifyUser(params[KEY.NAME],
                                                    params[KEY.IDENTITY_ID],
                                                    filepath, link) == 200:

                    return self.render("comfirm-submit.html", id=id)

        return self.write('error')
    def post(self):
        
        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)
        #加入邮件
        params[KEY.EMAIL] = user[KEY.EMAIL]
        #对图片名称加密
        md5_encode = hashlib.md5()
        md5_encode.update(str(id))
        saveName = md5_encode.hexdigest()

        #saveName = id
        nowpath = os.path.dirname(__file__).replace("handler", "static")
        path = os.path.join(nowpath, "images", "head")
        filepath = uploadImageUtils.uploadImageUtils(self.request, "fileImage", saveName, path)

        if filepath:
            params[KEY.NAME] = self.get_argument('realname')

            params[KEY.IDENTITY_ID] = self.get_argument('realID')
            #-----------------------------------------------------
            params[KEY.AVATAR] = saveName + filepath[-4:]

            #防止有人跨过登录这个地址
            while (True):

                idencode = ''.join(random.sample(string.ascii_letters, 4))
                tempParams = {}
                tempParams[KEY.IDENCODE] = idencode
                if db.get_user_verify_info(tempParams) == None:
                    params[KEY.IDENCODE] = idencode
                    break

            verify = db.add_user_verify(params)

            if verify != -1:

                link = "http://120.24.208.130:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                # link = "http://localhost:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                if sendEmail.sendEmailForVerifyUser(params[KEY.NAME], params[KEY.IDENTITY_ID], filepath, link) == 200:

                    return self.render("comfirm-submit.html", id=id)

        return self.write('error')
Exemplo n.º 6
0
    def get(self, idencode):

        params = {}
        params[KEY.IDENCODE] = idencode

        #先判段是是否有人确认过了
        verify_user_info = db.get_user_verify_info(params)
        if verify_user_info is None:
            return self.write('the link is fail')

        #没有的话 清除数据
        db.clear_verify_user_info(verify_user_info)

        #判段时间是否失效

        s = verify_user_info[KEY.TIME]
        emailTime = time.mktime(s.timetuple())
        nowTime = time.time()
        timeInterval = nowTime - emailTime

        verify_user_info[KEY.EMAIL] = verify_user_info[KEY.EMAIL].replace(
            "%40", "@")
        if timeInterval > 86400:
            sendEmail.sendEmail([verify_user_info[KEY.EMAIL]], "认证失败消息",
                                "您的实名认证失败,请重新认证")
            return self.write(
                'the link is fail (The effective time has passed.)')
        else:
            verify_user_info[KEY.IS_VERIFY] = 1

            success = db.update_user(verify_user_info)
            if success:
                return self.write("success comfirm")
            else:
                sendEmail.sendEmail([verify_user_info[KEY.EMAIL]], "认证失败消息",
                                    "您的实名认证失败,请重新认证")
                return self.write("server error")