~edwargix/git.sr.ht

36a30e0bd4ad9bacdd4d459fceae0f1d80c8c459 — Drew DeVault 6 years ago 408cce8
Prevent suspended users from pushing
2 files changed, 11 insertions(+), 1 deletions(-)

M gitsrht-shell
M gitsrht/blueprints/internal.py
M gitsrht-shell => gitsrht-shell +2 -0
@@ 76,4 76,6 @@ elif r.status_code == 200:
    sys.stderr.close()
    os.execvp(cmd[0], cmd)
else:
    if "why" in response:
        print(response["why"])
    sys.exit(128)

M gitsrht/blueprints/internal.py => gitsrht/blueprints/internal.py +9 -1
@@ 9,10 9,11 @@ from gitsrht.repos import GitRepoApi
from gitsrht.types import User, Repository, RepoVisibility, Redirect
from scmsrht.access import has_access, UserAccess
from scmsrht.urls import get_clone_urls
from srht.config import get_origin
from srht.config import cfg, get_origin
from srht.crypto import verify_request_signature
from srht.database import db
from srht.flask import csrf_bypass
from srht.oauth import UserType
from srht.validation import Validation
import base64
import os


@@ 76,4 77,11 @@ def push_check():
    if not has_access(repo, access, user):
        return { }, 401

    if access == UserAccess.write and user.user_type == UserType.suspended:
        return {
            "why": "Your account has been suspended with the following notice:\n" +
                user.suspension_notice + "\n" +
                "Please contact support: " + cfg("sr.ht", "owner-email"),
        }, 401

    return push_context(user, repo), 200