<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### 1.在生成驗證碼的時候存入memcached中 自定義memcached的set、get、delete操作,便于后期修改 ``` import memcache # debug=True,如果出現錯誤,會打印出來 cache = memcache.Client(["127.0.0.1:11211"],debug=True) # 設置 def set(key,value,timeout=60): return cache.set(key,value,timeout) # 獲取 def get(key): return cache.get(key) # 刪除 def delete(key): return cache.delete(key) ``` 將生成的驗證碼存入memcached中 ``` zlcache.set(email,captcha) ``` ### 2.利用ajax向服務器發起post請求 ``` $(function () { $("#submit").click(function (event) { event.preventDefault(); var emailE = $("input[name='email']"); var captchaE = $("input[name='captcha']"); var email = emailE.val(); var captcha = captchaE.val(); zlajax.post({ 'url': '/cms/resetemail/', 'data': { 'email': email, 'captcha': captcha }, 'success': function (data) { if(data['code'] == 200){ console.log(captcha) emailE.val(""); captchaE.val(""); zlalert.alertSuccessToast('郵箱修改成功!'); }else{ zlalert.alertInfo(data['message']); } }, 'fail': function (error) { zlalert.alertNetworkError(); } }); }); }); ``` ### 3.接收post請求的表單數據,進行判斷處理 ``` class ResetEmailForm(BaseForm): email = StringField(validators=[Email(message='請輸入正確格式的郵箱!')]) captcha = StringField(validators=[Length(6,20)]) def validate_captcha(self,field): print(field) captcha = field.data email = self.email.data captcha_cache = zlcache.get(email) print(captcha.lower(),captcha_cache.lower()) if not captcha_cache or captcha.lower() != captcha_cache.lower(): raise ValidationError('郵箱驗證碼錯誤!') def validate_email(self,field): email = field.data user = g.cms_user if user.email == email: raise ValidationError('不能修改為相同的郵箱!') ``` ``` 自定義驗證器需要這樣寫 def validate_captcha(self.field): pass ``` ### 4.處理驗證過程 ``` def post(self): print(request.form) form = ResetEmailForm(request.form) if form.validate(): email = form.email.data g.cms_user.email = email db.session.commit() return restful.success() else: return restful.params_error(form.get_error()) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看