コード例 #1
0
    def cancel(self, request, pk=None):
        """
        Cancel an account via token
        """
        serializer = serializers.CancelAccountSerializer(data=request.DATA,
                                                         many=False)
        if not serializer.is_valid():
            raise exc.WrongArguments(
                _("Invalid, are you sure the token is correct?"))

        try:
            max_age_cancel_account = getattr(settings,
                                             "MAX_AGE_CANCEL_ACCOUNT", None)
            user = get_user_for_token(serializer.data["cancel_token"],
                                      "cancel_account",
                                      max_age=max_age_cancel_account)

        except exc.NotAuthenticated:
            raise exc.WrongArguments(
                _("Invalid, are you sure the token is correct?"))

        if not user.is_active:
            raise exc.WrongArguments(
                _("Invalid, are you sure the token is correct?"))

        user.cancel()
        return response.NoContent()
コード例 #2
0
ファイル: api.py プロジェクト: cubettech/taiga-back
    def cancel(self, request, pk=None):
        """
        Cancel an account via token
        """
        serializer = serializers.CancelAccountSerializer(data=request.DATA, many=False)
        if not serializer.is_valid():
            raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))

        try:
            max_age_cancel_account = getattr(settings, "MAX_AGE_CANCEL_ACCOUNT", None)
            user = get_user_for_token(serializer.data["cancel_token"], "cancel_account", max_age=max_age_cancel_account)

        except exc.NotAuthenticated:
            raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))

        if not user.is_active:
            raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))

        user.cancel()
        return response.NoContent()
コード例 #3
0
def test_invalid_token_scope():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    user_from_token = get_user_for_token(token, "testing_invalid_scope")
コード例 #4
0
def test_invalid_token():
    user = f.UserFactory.create(email="*****@*****.**")
    user_from_token = get_user_for_token("testing_invalid_token", "testing_scope")
コード例 #5
0
def test_valid_token():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    user_from_token = get_user_for_token(token, "testing_scope")
    assert user.id == user_from_token.id
コード例 #6
0
ファイル: test_tokens.py プロジェクト: cubettech/taiga-back
def test_invalid_token_scope():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    get_user_for_token(token, "testing_invalid_scope")
コード例 #7
0
ファイル: test_tokens.py プロジェクト: cubettech/taiga-back
def test_invalid_token_expiration():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    get_user_for_token(token, "testing_scope", max_age=1)
コード例 #8
0
ファイル: test_tokens.py プロジェクト: cubettech/taiga-back
def test_invalid_token():
    f.UserFactory.create(email="*****@*****.**")
    get_user_for_token("testing_invalid_token", "testing_scope")
コード例 #9
0
ファイル: test_tokens.py プロジェクト: cubettech/taiga-back
def test_valid_token():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    user_from_token = get_user_for_token(token, "testing_scope")
    assert user.id == user_from_token.id
コード例 #10
0
def test_invalid_token_expiration():
    user = f.UserFactory.create(email="*****@*****.**")
    token = get_token_for_user(user, "testing_scope")
    get_user_for_token(token, "testing_scope", max_age=1)