示例#1
0
文件: auth.py 项目: crazymouse0/plog
def check_csrf():
    if 'csrf' not in request.cookies:
        g.csrf = randstring()
    else:
        g.csrf = request.cookies['csrf']

    if request.method not in ('HEAD', 'GET'):
        if 'csrf' not in request.form or 'csrf' not in request.cookies:
            g.csrf = randstring()
            abort(403)
        if request.form['csrf'] != request.cookies['csrf']:
            g.csrf = randstring()
            abort(403)
示例#2
0
文件: auth.py 项目: changhu2013/plog
def check_csrf():
    if 'csrf' not in request.cookies:
        g.csrf = randstring()
    else:
        g.csrf = request.cookies['csrf']

    if request.method not in ('HEAD', 'GET'):
        if 'csrf' not in request.form or 'csrf' not in request.cookies:
            g.csrf = randstring()
            abort(403)
        if request.form['csrf'] != request.cookies['csrf']:
            g.csrf = randstring()
            abort(403)
示例#3
0
 def __init__(self, *args, **kwargs):
     super(Commenter, self).__init__(*args, **kwargs)
     if self.cookie is None:
         self.cookie = randstring()
     self.when = datetime.utcnow()
示例#4
0
 def __init__(self, *args, **kwargs):
     super(Commenter, self).__init__(*args, **kwargs)
     if self.cookie is None:
         self.cookie = randstring()
     self.when = datetime.utcnow()