Exemplo n.º 1
0
def check_admin_and_session():
    if session and 'username' in session.keys():
        try:
            if not auth.auth(session['_id'], session['username'], session['token']):
                for x in session.keys():
                    session.pop(x, None)
                return redirect('/')
            elif not "static" in request.path:
                auth.update_session(session['_id'], session['username'],\
                session['token'], {"current_page": request.path})
        except:
            for x in session.keys():
                session.pop(x, None)
            return redirect('/')
Exemplo n.º 2
0
def set_mobile_session(_id, username, token):
    if auth.auth(_id, username, token):
        session['_id'] = _id
        session['username'] = username
        session['token'] = token
        stored_session = auth.get_session(_id, username, token)
        if stored_session:
            for k,v in stored_session.iteritems():
                session[k] = v
        if "current_page" in session.keys():
            return redirect(session['current_page'])
        else:
            return redirect('/')
    else:
        abort(404)