Beispiel #1
0
def get_user(uid):
    user = getUser(uid)

    if user is None:
        return render_template("user404.html", email=uid)

    return render_template("user.html", login=not session.get('userId'), own=(str(user.pk) == session.get('userId')),
                           email=user.email.lower(),
                           devices=user.devices, glassConnected=Glass.has_glass_connected(user))
Beispiel #2
0
def logout():
    try:
        user = getUser(session['userId'])
        creds = MongoStorage(user).get()
        http = httplib2.Http()
        creds.revoke(http)
    except Exception as e:
        pass

    session.pop('userId', None)
    session.pop('user', None)
    return redirect("/")
Beispiel #3
0
def connect_glass():
    if 'userId' not in session:
        abort(403)

    user = getUser(session['userId'])
    model = "Glass"
    manufacturer = "Google"
    _type = "Glass"

    hasDevice = Glass.has_glass_connected(user)

    if not hasDevice:
        user.devices.append(Device(deviceId=Glass.DEVICE_ID, type=_type, model=model, manufacturer=manufacturer))
        user.save()
    return redirect("/")