diff --git a/endpoints/api.py b/endpoints/api.py
index 2a18edf4c..95912b570 100644
--- a/endpoints/api.py
+++ b/endpoints/api.py
@@ -118,6 +118,26 @@ def get_logged_in_user():
return jsonify(user_view(user))
+@app.route('/api/user/private', methods=['GET'])
+@api_login_required
+def get_user_private_count():
+ user = current_user.db_user()
+ private_repos = model.get_private_repo_count(user.username)
+ repos_allowed = 0
+
+ if user.stripe_id:
+ cus = stripe.Customer.retrieve(user.stripe_id)
+ if cus.subscription:
+ plan = get_plan(cus.subscription.plan.id)
+ if plan:
+ repos_allowed = plan['privateRepos']
+
+ return jsonify({
+ 'privateCount': private_repos,
+ 'reposAllowed': repos_allowed
+ })
+
+
@app.route('/api/user/convert', methods=['POST'])
@api_login_required
def convert_user_to_organization():
@@ -485,7 +505,11 @@ def get_organization_private_allowed(orgname):
if organization.stripe_id:
cus = stripe.Customer.retrieve(organization.stripe_id)
if cus.subscription:
- repos_allowed = get_plan(cus.subscription.plan.id)
+ repos_allowed = 0
+ plan = get_plan(cus.subscription.plan.id)
+ if plan:
+ repos_allowed = plan['privateRepos']
+
return jsonify({
'privateAllowed': (private_repos < repos_allowed)
})
diff --git a/static/directives/header-bar.html b/static/directives/header-bar.html
index 169c9bf06..6df3e1fe8 100644
--- a/static/directives/header-bar.html
+++ b/static/directives/header-bar.html
@@ -38,14 +38,18 @@
{{ user.username }}
- 1
+
+ {{ (user.askForPassword ? 1 : 0) + (overPlan ? 1 : 0) }}
+