Ejemplo n.º 1
0
def logout(request):
    try:
        old_auth_hash = request.COOKIES['auth']
    except (KeyError):
        return render_to_response('frontend/login.html')

    r = Redis(db=0)
    user_id = r.get('auth:%s:id' % old_auth_hash)
    auth_hash = hashlib.sha224().hexdigest()
    r.set('uid:%s:auth' % user_id, auth_hash)
    r.set('auth:%s' % auth_hash, user_id)
    r.delete('auth:%s' % old_auth_hash)

    return render_to_response('frontend/login.html')