예제 #1
0
파일: apply.py 프로젝트: krizex/senguoSmh
	def post(self):
		#极验验证
		challenge = self.get_argument("geetest_challenge")
		validate = self.get_argument("geetest_validate")
		seccode = self.get_argument("geetest_seccode")
		# print (challenge,)
		# print (seccode)
		# print (validate,'validate')
		if len(challenge) <2 or len(seccode) <2 or len(validate) <2:
			return self.send_fail('请先完成图形验证')
		gt = geetest.geetest(captcha_id, private_key)
		result = gt.geetest_validate(challenge, validate, seccode)
		if not result:
			return self.send_fail('验证码错误')

		try:
			if_admin = self.session.query(models.ShopAdmin).filter_by(id=self.current_user.id,role=1).first()
		except:
			if_admin = None
		if if_admin:
			return self.send_fail("您已是卖家")
		#判断申请店铺的微信是否已是某店铺的管理员身份
		# try:
		# 	if_shopadmin = self.session.query(models.HireLink).join(models.ShopStaff,models.HireLink.staff_id == models.ShopStaff.id)\
		# 	.filter(models.HireLink.active==1,models.HireLink.work ==9 ,models.ShopStaff.id == self.current_user.id).first()
		# except:
		# 	if_shopadmin = None
		# try:
		# 	if_shop = self.session.query(models.Shop).filter_by(id = if_admin.shop_id).first()
		# except:
		# 	if_shop = None
		# if if_shopadmin:
		# 	return self.send_fail('该账号已是'+if_shop.shop_name+'的管理员,不能使用该账号申请店铺,若要使用该账号,请退出'+if_shop.shop_name+'管理员身份更换或其它账号')

		if not self.args['phone']:
			return self.send_fail("please input your phone number")
		if not self.args["realname"]:
			return self.send_fail("please input your realname")
		if not check_msg_token(phone=self.args['phone'], code=int(self.args["code"])):
			return self.send_fail(error_text="验证码过期或者不正确")

		if len(self.args["phone"])>11:
			return self.send_fail("手机号格式错误")
		if len(self.args["realname"])>20:
			return self.send_fail("真实姓名请不要超过20个字")
		if len(self.args["wx_username"])>20:
			return self.send_fail("微信号请不要超过20个字")

		if_normal_admin = self.session.query(models.ShopAdmin).filter_by(id=self.current_user.id).first()
		# print(if_normal_admin)
		self.current_user.accountinfo.phone=self.args["phone"]
		self.current_user.accountinfo.realname=self.args["realname"]
		self.current_user.accountinfo.wx_username=self.args["wx_username"]
		if if_normal_admin:
			if_normal_admin.role=1
			if_normal_admin.privileges = -1
		else:
			self.session.add(models.ShopAdmin(id=self.current_user.id))
		self.session.commit()
		return self.send_success()
예제 #2
0
파일: apply.py 프로젝트: krizex/senguoSmh
    def get(self):
        if not self.current_user:
            return self.redirect(self.reverse_url("ApplyLogin"))
        try:
            if_admin = self.session.query(models.ShopAdmin).filter_by(
                id=self.current_user.id, role=1).first()
        except:
            if_admin = None

        if if_admin:
            return self.redirect(self.reverse_url("switchshop"))

        # try:
        # 	if_shop_admin = self.session.query(models.HireLink).join(models.ShopStaff,models.HireLink.staff_id == models.ShopStaff.id)\
        # 	.filter(models.HireLink.active==1,models.HireLink.work ==9 ,models.ShopStaff.id == account_id).first()
        # except:
        # 	if_shop_admin = None
        # try:
        # 	if_shop = self.session.query(models.Shop).filter_by(id = if_shop_admin.shop_id).first()
        # except:
        # 	if_shop = None
        # if if_shop_admin:
        # 	return self.redirect(self.reverse_url("switchshop"))
        phone = self.current_user.accountinfo.phone if self.current_user.accountinfo.phone else ""
        logo_img = self.current_user.accountinfo.headimgurl_small
        nickname = self.current_user.accountinfo.nickname
        realname = self.current_user.accountinfo.realname if self.current_user.accountinfo.phone else ""
        wx_username = self.current_user.accountinfo.wx_username if self.current_user.accountinfo.phone else ""
        #添加极验验证码 woody 8.20
        gt = geetest.geetest(captcha_id, private_key)
        url = ""
        httpsurl = ""
        try:
            challenge = gt.geetest_register()
        except:
            challenge = ""
        # print(challenge,'challenge',len(challenge))
        if isinstance(challenge, bytes):
            challenge = challenge.decode('utf-8')
        if len(challenge) == 32:
            url = "http://%s%s&challenge=%s&product=%s" % (
                BASE_URL, captcha_id, challenge, product)
            httpsurl = "https://%s%s&challenge=%s&product=%s" % (
                BASE_URL, captcha_id, challenge, product)
            # print(url)
        return self.render('apply/home.html',
                           logo_img=logo_img,
                           nickname=nickname,
                           phone=phone,
                           realname=realname,
                           wx_username=wx_username,
                           url=url)
예제 #3
0
파일: apply.py 프로젝트: krizex/senguoSmh
    def post(self):
        username = self.get_argument("email")
        password = self.get_argument("password")

        challenge = self.get_argument("geetest_challenge")
        validate = self.get_argument("geetest_validate")
        seccode = self.get_argument("geetest_seccode")
        # print(challenge)
        # print(seccode)
        # print(validate,'validate')
        gt = geetest.geetest(captcha_id, private_key)
        result = gt.geetest_validate(challenge, validate, seccode)
        if result:
            self.write("success")
        else:
            self.write("fail")
예제 #4
0
파일: apply.py 프로젝트: krizex/senguoSmh
	def post(self):
		username = self.get_argument("email")
		password = self.get_argument("password")

		challenge = self.get_argument("geetest_challenge")
		validate = self.get_argument("geetest_validate")
		seccode = self.get_argument("geetest_seccode")
		# print(challenge)
		# print(seccode)
		# print(validate,'validate')
		gt = geetest.geetest(captcha_id, private_key)
		result = gt.geetest_validate(challenge, validate, seccode)
		if result:
			self.write("success")
		else:
			self.write("fail")
예제 #5
0
파일: apply.py 프로젝트: krizex/senguoSmh
	def get(self):
		gt = geetest.geetest(captcha_id, private_key)
		url = ""
		httpsurl = ""
		try:
			challenge = gt.geetest_register()
		except:
			challenge = ""
		# print(challenge,'challenge',len(challenge))
		if isinstance(challenge,bytes):
			challenge = challenge.decode('utf-8')
		if len(challenge) == 32:
			url = "http://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
			httpsurl = "https://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
			# print(url)
		self.render("apply/login.html", url=url)
예제 #6
0
파일: apply.py 프로젝트: krizex/senguoSmh
 def get(self):
     gt = geetest.geetest(captcha_id, private_key)
     url = ""
     httpsurl = ""
     try:
         challenge = gt.geetest_register()
     except:
         challenge = ""
     # print(challenge,'challenge',len(challenge))
     if isinstance(challenge, bytes):
         challenge = challenge.decode('utf-8')
     if len(challenge) == 32:
         url = "http://%s%s&challenge=%s&product=%s" % (
             BASE_URL, captcha_id, challenge, product)
         httpsurl = "https://%s%s&challenge=%s&product=%s" % (
             BASE_URL, captcha_id, challenge, product)
         # print(url)
     self.render("apply/login.html", url=url)
예제 #7
0
파일: apply.py 프로젝트: krizex/senguoSmh
	def get(self):
		if not self.current_user:
			return self.redirect(self.reverse_url("ApplyLogin"))
		try:
			if_admin = self.session.query(models.ShopAdmin).filter_by(id=self.current_user.id,role=1).first()
		except:
			if_admin = None
			
		if if_admin:
			return self.redirect(self.reverse_url("switchshop"))

		# try:
		# 	if_shop_admin = self.session.query(models.HireLink).join(models.ShopStaff,models.HireLink.staff_id == models.ShopStaff.id)\
		# 	.filter(models.HireLink.active==1,models.HireLink.work ==9 ,models.ShopStaff.id == account_id).first()
		# except:
		# 	if_shop_admin = None
		# try:
		# 	if_shop = self.session.query(models.Shop).filter_by(id = if_shop_admin.shop_id).first()
		# except:
		# 	if_shop = None
		# if if_shop_admin:
		# 	return self.redirect(self.reverse_url("switchshop"))
		phone = self.current_user.accountinfo.phone if self.current_user.accountinfo.phone else ""
		logo_img = self.current_user.accountinfo.headimgurl_small
		nickname = self.current_user.accountinfo.nickname
		realname = self.current_user.accountinfo.realname if self.current_user.accountinfo.phone else ""
		wx_username = self.current_user.accountinfo.wx_username if self.current_user.accountinfo.phone else ""
		#添加极验验证码 woody 8.20
		gt = geetest.geetest(captcha_id, private_key)
		url = ""
		httpsurl = ""
		try:
			challenge = gt.geetest_register()
		except:
			challenge = ""
		# print(challenge,'challenge',len(challenge))
		if isinstance(challenge,bytes):
			challenge = challenge.decode('utf-8')
		if len(challenge) == 32:
			url = "http://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
			httpsurl = "https://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
			# print(url)
		return self.render('apply/home.html',logo_img=logo_img,nickname=nickname,phone=phone,realname=realname,wx_username=wx_username,url=url)
예제 #8
0
파일: webMain.py 프로젝트: cyhhao/SunPass
            allPass = loadPassword(user)
            if id in allPass:
                del allPass[id]
                savePassword(user, allPass)
                return resJSON(1, "delete ok")
            else:
                return resJSON(1, "delete already")
    except Exception:
        print Exception

    return resJSON(0, "Error. try refresh the page")


@post("/logout")
@Auth
@Xsrf
def deletePass(user, session):
    guest_session_id = request.get_cookie("guest")
    Session.deleteGuest(guest_session_id)
    response.delete_cookie("guest")
    response.delete_cookie("token")
    response.delete_cookie("session")
    return resJSON(1, "bye")


if __name__ == "__main__":
    makeDir()
    readUsers()
    gt = geetest(captcha_id, private_key)
    run(host="127.0.0.1", port=port)
예제 #9
0
파일: apply.py 프로젝트: krizex/senguoSmh
    def post(self):
        #极验验证
        challenge = self.get_argument("geetest_challenge")
        validate = self.get_argument("geetest_validate")
        seccode = self.get_argument("geetest_seccode")
        # print (challenge,)
        # print (seccode)
        # print (validate,'validate')
        if len(challenge) < 2 or len(seccode) < 2 or len(validate) < 2:
            return self.send_fail('请先完成图形验证')
        gt = geetest.geetest(captcha_id, private_key)
        result = gt.geetest_validate(challenge, validate, seccode)
        if not result:
            return self.send_fail('验证码错误')

        try:
            if_admin = self.session.query(models.ShopAdmin).filter_by(
                id=self.current_user.id, role=1).first()
        except:
            if_admin = None
        if if_admin:
            return self.send_fail("您已是卖家")
        #判断申请店铺的微信是否已是某店铺的管理员身份
        # try:
        # 	if_shopadmin = self.session.query(models.HireLink).join(models.ShopStaff,models.HireLink.staff_id == models.ShopStaff.id)\
        # 	.filter(models.HireLink.active==1,models.HireLink.work ==9 ,models.ShopStaff.id == self.current_user.id).first()
        # except:
        # 	if_shopadmin = None
        # try:
        # 	if_shop = self.session.query(models.Shop).filter_by(id = if_admin.shop_id).first()
        # except:
        # 	if_shop = None
        # if if_shopadmin:
        # 	return self.send_fail('该账号已是'+if_shop.shop_name+'的管理员,不能使用该账号申请店铺,若要使用该账号,请退出'+if_shop.shop_name+'管理员身份更换或其它账号')

        if not self.args['phone']:
            return self.send_fail("please input your phone number")
        if not self.args["realname"]:
            return self.send_fail("please input your realname")
        if not check_msg_token(phone=self.args['phone'],
                               code=int(self.args["code"])):
            return self.send_fail(error_text="验证码过期或者不正确")

        if len(self.args["phone"]) > 11:
            return self.send_fail("手机号格式错误")
        if len(self.args["realname"]) > 20:
            return self.send_fail("真实姓名请不要超过20个字")
        if len(self.args["wx_username"]) > 20:
            return self.send_fail("微信号请不要超过20个字")

        if_normal_admin = self.session.query(
            models.ShopAdmin).filter_by(id=self.current_user.id).first()
        # print(if_normal_admin)
        self.current_user.accountinfo.phone = self.args["phone"]
        self.current_user.accountinfo.realname = self.args["realname"]
        self.current_user.accountinfo.wx_username = self.args["wx_username"]
        if if_normal_admin:
            if_normal_admin.role = 1
            if_normal_admin.privileges = -1
        else:
            self.session.add(models.ShopAdmin(id=self.current_user.id))
        self.session.commit()
        return self.send_success()