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())
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()))
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)
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()
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()))