Esempio n. 1
0
def create_email_authorization_for_repo(namespace_name, repository_name, email):
    try:
        repo = _basequery.get_existing_repository(namespace_name, repository_name)
    except Repository.DoesNotExist:
        raise DataModelException("Invalid repository %s/%s" % (namespace_name, repository_name))

    return RepositoryAuthorizedEmail.create(repository=repo, email=email, confirmed=False)
Esempio n. 2
0
def get_email_authorized_for_repo(namespace, repository, email):
    try:
        return (RepositoryAuthorizedEmail.select(
            RepositoryAuthorizedEmail, Repository,
            Namespace).join(Repository).join(
                Namespace,
                on=(Repository.namespace_user == Namespace.id)).where(
                    Namespace.username == namespace,
                    Repository.name == repository,
                    RepositoryAuthorizedEmail.email == email).get())
    except RepositoryAuthorizedEmail.DoesNotExist:
        return None
Esempio n. 3
0
def confirm_email_authorization_for_repo(code):
    try:
        found = (RepositoryAuthorizedEmail.select(
            RepositoryAuthorizedEmail, Repository,
            Namespace).join(Repository).join(
                Namespace, on=(Repository.namespace_user == Namespace.id)
            ).where(RepositoryAuthorizedEmail.code == code).where(
                Repository.state != RepositoryState.MARKED_FOR_DELETION).get())
    except RepositoryAuthorizedEmail.DoesNotExist:
        raise DataModelException("Invalid confirmation code.")

    found.confirmed = True
    found.save()

    return found