Exemplo n.º 1
0
def verifica_user():
    user_json = session['barzinga_user']
    user = User.query().filter(User.email == user_json["email"]).get()

    dx = user_json['email'].endswith('@dextra-sw.com')
    mutant = user_json['email'].endswith('@mutantbr.com')
    if not dx and not mutant:
        raise Exception('Invalid domain %s' % user_json['email'])

    if not user:
        # user = User(name = user_json['name'], email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str(''))
        user = User(name = '', email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, infra=False, rfid=str(''), active = True)

        user.put()

        user_document = search.Document(
            fields=[
                search.TextField(name='name', value=user.name),
                search.TextField(name='email', value=user.email)
            ])

        search.Index(name='user').put(user_document)
    elif not user.photo_url:
        user.photo_url = user_json['picture']
        user.put()

    identity = Identity(user.key.id())
    identity_changed.send(current_app._get_current_object(), identity=identity)
Exemplo n.º 2
0
def verifica_user():
    user_json = session['barzinga_user']
    user = User.query().filter(User.email == user_json["email"]).get()

    if not user:
        # user = User(name = user_json['name'], email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str(''))
        user = User(name = '', email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str(''))

        user.put()

        user_document = search.Document(
            fields=[
                search.TextField(name='name', value=user.name),
                search.TextField(name='email', value=user.email)
            ])

        search.Index(name='user').put(user_document)
    elif not user.photo_url:
        user.photo_url = user_json['picture']
        user.put()

    identity = Identity(user.key.id())
    identity_changed.send(current_app._get_current_object(), identity=identity)