def register(): try: if request.method == "POST": print request.method authcode = request.form['form-verify'] email = request.form['form-username'] password = genMd5(request.form['form-password']) name = request.form['form-name'] print '==>', authcode.upper(), session["auth_code"].upper() if session["auth_code"].upper() == authcode.upper(): re = resume() registerSuccess = re.insert(username=email, password=password, realName=name) # 如果插入失败registerSuccess返回啥哩? session.pop('auth_code') if registerSuccess: try: emailUrl = sendVerifyEmail(email) return jsonify({"status": 1, "msg": "记得去确认" + ( "<a href='" + emailUrl + "'>邮件</a>。" if len( emailUrl) > 0 else '邮件') + "啊!", "nexturl": "setting"}) except: print "send verfiy email fails" + format_exc() return jsonify({"status": 0, "msg": "邮件发送有问题"}) else: return jsonify({"status": 0, "msg": "验证码有问题"}) else: return render_template("register.html") except: print format_exc()
def register(): try: if request.method == "POST": formrole = request.form['form-role'] authcode = request.form['form-verify'] email = request.form['form-username'] password = genMd5(request.form['form-password']) name = request.form['form-name'] if session["auth_code"].upper() == authcode.upper(): print 'hello world' registerSuccess = resume().insert(username=email, password=password, realName=name, role='r' if formrole == 'resume' else 'h').execute() session.pop('auth_code') resu = resume().select("*").where(username=email).execute() CurrentSession.put("user", resu[0]) try: return jsonify({"status": 1, "msg": "hello", "nexturl": "setting"}) except: logger.warn("send verfiy email fails" + format_exc()) return jsonify({"status": 0, "msg": "邮件发送有问题"}) else: return jsonify({"status": 0, "msg": "验证码有问题"}) else: return render_template("register.html") except: logger.info(format_exc())
def login(): try: postName = request.form["form-username"] postpassword = request.form["form-password"] resu = resume().select("*").where(username=postName).execute() if resu is None or len(resu) == 0: return jsonify({"status": 0, "msg": "用户不存在"}) if genMd5(postpassword) == resu[0].password: CurrentSession.put("user", resu[0]) if resu[0].myDomain is None or resu[0].myDomain == 'null' or len(resu[0].myDomain) == 0: resu[0].myDomain = 'setting' return jsonify({"status": 1, "msg": "登录成功", "nexturl": resu[0].myDomain}) else: return jsonify({"status": 0, "msg": "用户或密码错误"}) except: logger(format_exc()) return jsonify({"status": 0, "msg": "服务器异常"})
def login(): try: postName = request.form["form-username"] postpassword = request.form["form-password"] resu = resume().select("password", "myDomain").where(username=postName) print resu if resu is None or len(resu) == 0: return jsonify({"status": 0, "msg": "用户不存在"}) if genMd5(postpassword) == resu[0].password: session['user'] = postName session['myDomain'] = resu[0].myDomain print "login ==> ",postName, resu[0].myDomain if resu[0].myDomain is None or resu[0].myDomain == 'null' or len(resu[0].myDomain) == 0: resu[0].myDomain = 'setting' return jsonify({"status": 1, "msg": "登录成功", "nexturl": resu[0].myDomain}) else: return jsonify({"status": 0, "msg": "用户或密码错误"}) except: print format_exc()