예제 #1
0
def create_or_login(resp):
    logger.debug("Inside create_or_login")
    session['openid'] = resp.identity_url
    user = UserAccount.objects(openid=resp.identity_url).first()
    if user is None:
        logger.debug("Creating user '%s' <%s>", resp.fullname, resp.email)
        user = UserAccount(openid=resp.identity_url, email=resp.email, full_name=resp.fullname, short_name=resp.nickname)
        user.save()
    else:
        logger.debug("Logged in user: '******' <%s>", user.full_name, user.email)
    return redirect(oid.get_next_url())
예제 #2
0
def get_current_user(email):
    """Retrieve a user account by their email address."""
    if "current" == email:
        if g.user is not None:
            return Response(g.user.to_json(), mimetype='application/json')
        else:
            return Response(status=404)
    else:
        return(JsonResponse(UserAccount.objects(email=email).first()))
예제 #3
0
파일: user.py 프로젝트: slickqa/slickqaweb
def update_user_account(email):
    """Update a user's account info."""
    orig = UserAccount.objects(email=email).first()
    if orig is None:
        return Response(status=404)
    update_event = events.UpdateEvent(before=orig)
    deserialize_that(read_request(), orig)
    orig.save()
    update_event.after(orig)
    return JsonResponse(orig)
예제 #4
0
def lookup_current_user():
    g.user = None
    if 'openid' in session:
        logger.debug('Found openid in session, value=%s', session['openid'])
        g.user = UserAccount.objects(openid=session['openid']).first()
예제 #5
0
파일: user.py 프로젝트: slickqa/slickqaweb
def get_current_user(email):
    """Retrieve a user account by their email address."""
    if "current" == email:
        return Response(status=404)
    else:
        return(JsonResponse(UserAccount.objects(email=email).first()))