Prechádzať zdrojové kódy

feat(api): expose User.locked as a read-only boolean

Peter Thomassen 6 rokov pred
rodič
commit
f9d2ef06e9
2 zmenil súbory, kde vykonal 55 pridanie a 1 odobranie
  1. 6 1
      api/desecapi/serializers.py
  2. 49 0
      docs/authentication.rst

+ 6 - 1
api/desecapi/serializers.py

@@ -223,14 +223,19 @@ class DonationSerializer(serializers.ModelSerializer):
 
 
 class UserSerializer(djoserSerializers.UserSerializer):
+    locked = serializers.SerializerMethodField()
 
     class Meta(djoserSerializers.UserSerializer.Meta):
         fields = tuple(User.REQUIRED_FIELDS) + (
             User.USERNAME_FIELD,
             'dyn',
             'limit_domains',
+            'locked',
         )
-        read_only_fields = ('dyn', 'limit_domains',)
+        read_only_fields = ('dyn', 'limit_domains', 'locked',)
+
+    def get_locked(self, obj):
+        return bool(obj.locked)
 
 
 class UserCreateSerializer(djoserSerializers.UserCreateSerializer):

+ 49 - 0
docs/authentication.rst

@@ -143,6 +143,55 @@ The server will delete the token and respond with ``204 No Content``.
 Manage Account
 ~~~~~~~~~~~~~~
 
+Field Reference
+```````````````
+
+A JSON object representing a user has the following structure::
+
+    {
+        "dyn": false,
+        "email": "address@example.com",
+        "limit_domains": 5,
+        "locked": false
+    }
+
+Field details:
+
+``dyn``
+    :Access mode: read-only (deprecated)
+
+    Indicates whether the account is restricted to dynDNS domains under
+    dedyn.io.
+
+``email``
+    :Access mode: read, write
+
+    Email address associated with the account.  This address must be valid
+    in order to submit support requests to deSEC.
+
+``limit_domains``
+    :Access mode: read-only
+
+    Maximum number of DNS zones the user can create.
+
+``locked``
+    :Access mode: read-only
+
+    Indicates whether the account is locked.  If so, publication of DNS
+    record changes will be adjourned.
+
+
+Retrieve Account Information
+````````````````````````````
+
+To request information about your account, send a ``GET`` request to the
+``auth/me/`` endpoint::
+
+    http GET \
+        https://desec.io/api/v1/auth/me/ \
+        Authorization:"Token i+T3b1h/OI+H9ab8tRS98stGtURe"
+
+
 Change Email Address
 ````````````````````