def checkOAuthUser(request,code): try: service = oauth.get_service(code) response = service.people().get(userId='me').execute() oauth_id = response["id"] domain = response["domain"] emails = response["emails"] username = emails[0]["value"] name = response["displayName"] print response print username if domain=="travelyaari.com": user=db.get_user(username,None,oauth_id,name) request.user=user getAuthorizedLinks(request) print request.allowed_links return True else: request.msg="INVALID_DOMAIN" return False except Exception as ex: print ex request.msg="AUTHENTICATION_FAILED" print request.msg return False
def get_username(request): if "username" in request.session: username=request.session["username"] if username.strip()!='': user=db.get_user(username.strip()) if user: request.username=user.username request.user=user getAuthorizedLinks(request) return username else: return None