Skip to content

Commit 877e522

Browse files
alexwwangvimalloc
authored andcommitted
improve document of loader functions more noticeable (#189)
1 parent 3d598d4 commit 877e522

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

flask_jwt_extended/jwt_manager.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ def user_claims_loader(self, callback):
200200
access token when :func:`~flask_jwt_extended.create_access_token` is
201201
called. By default, no extra user claims will be added to the JWT.
202202
203-
The callback function must be a function that takes only one argument,
203+
*HINT*: The callback function must be a function that takes only **one** argument,
204204
which is the object passed into
205205
:func:`~flask_jwt_extended.create_access_token`, and returns the custom
206206
claims you want included in the access tokens. This returned claims
207-
must be JSON serializable.
207+
must be *JSON serializable*.
208208
"""
209209
self._user_claims_callback = callback
210210
return callback
@@ -218,11 +218,11 @@ def user_identity_loader(self, callback):
218218
return the unmodified object that is passed in as the `identity` kwarg
219219
to the above functions.
220220
221-
The callback function must be a function that takes only one argument,
221+
*HINT*: The callback function must be a function that takes only **one** argument,
222222
which is the object passed into
223223
:func:`~flask_jwt_extended.create_access_token` or
224224
:func:`~flask_jwt_extended.create_refresh_token`, and returns the
225-
JSON serializable identity of this token.
225+
*JSON serializable* identity of this token.
226226
"""
227227
self._user_identity_callback = callback
228228
return callback
@@ -235,8 +235,8 @@ def expired_token_loader(self, callback):
235235
236236
{"msg": "Token has expired"}
237237
238-
The callback must be a function that takes zero arguments, and returns
239-
a Flask response.
238+
*HINT*: The callback must be a function that takes **zero** arguments, and returns
239+
a *Flask response*.
240240
"""
241241
self._expired_token_callback = callback
242242
return callback
@@ -249,9 +249,9 @@ def invalid_token_loader(self, callback):
249249
250250
{"msg": "<error description>"}
251251
252-
The callback must be a function that takes only one argument, which is
252+
*HINT*: The callback must be a function that takes only **one** argument, which is
253253
a string which contains the reason why a token is invalid, and returns
254-
a Flask response.
254+
a *Flask response*.
255255
"""
256256
self._invalid_token_callback = callback
257257
return callback
@@ -264,9 +264,9 @@ def unauthorized_loader(self, callback):
264264
265265
{"msg": "<error description>"}
266266
267-
The callback must be a function that takes only one argument, which is
267+
*HINT*: The callback must be a function that takes only **one** argument, which is
268268
a string which contains the reason why a JWT could not be found, and
269-
returns a Flask response.
269+
returns a *Flask response*.
270270
"""
271271
self._unauthorized_callback = callback
272272
return callback
@@ -280,8 +280,8 @@ def needs_fresh_token_loader(self, callback):
280280
281281
{"msg": "Fresh token required"}
282282
283-
The callback must be a function that takes no arguments, and returns
284-
a Flask response.
283+
*HINT*: The callback must be a function that takes **no** arguments, and returns
284+
a *Flask response*.
285285
"""
286286
self._needs_fresh_token_callback = callback
287287
return callback
@@ -294,8 +294,8 @@ def revoked_token_loader(self, callback):
294294
295295
{"msg": "Token has been revoked"}
296296
297-
The callback must be a function that takes no arguments, and returns
298-
a Flask response.
297+
*HINT*: The callback must be a function that takes **no** arguments, and returns
298+
a *Flask response*.
299299
"""
300300
self._revoked_token_callback = callback
301301
return callback
@@ -306,9 +306,9 @@ def user_loader_callback_loader(self, callback):
306306
automatically load an object when a protected endpoint is accessed.
307307
By default this is not used.
308308
309-
The callback must take one argument which is the identity JWT accessing
310-
the protected endpoint, and it must return any object (which can then
311-
be accessed via the :attr:`~flask_jwt_extended.current_user` LocalProxy
309+
*HINT*: The callback must take **one** argument which is the identity JWT
310+
accessing the protected endpoint, and it must return any object (which can
311+
then be accessed via the :attr:`~flask_jwt_extended.current_user` LocalProxy
312312
in the protected endpoint), or `None` in the case of a user not being
313313
able to be loaded for any reason. If this callback function returns
314314
`None`, the :meth:`~flask_jwt_extended.JWTManager.user_loader_error_loader`
@@ -327,8 +327,8 @@ def user_loader_error_loader(self, callback):
327327
328328
{"msg": "Error loading the user <identity>"}
329329
330-
The callback must be a function that takes one argument, which is the
331-
identity of the user who failed to load, and must return a Flask response.
330+
*HINT*: The callback must be a function that takes **one** argument, which is the
331+
identity of the user who failed to load, and must return a *Flask response*.
332332
"""
333333
self._user_loader_error_callback = callback
334334
return callback
@@ -339,9 +339,9 @@ def token_in_blacklist_loader(self, callback):
339339
a protected endpoint is accessed and will check if the JWT has been
340340
been revoked. By default, this callback is not used.
341341
342-
The callback must be a function that takes one argument, which is the
343-
decoded JWT (python dictionary), and returns `True` if the token
344-
has been blacklisted (or is otherwise considered revoked), or `False`
342+
*HINT*: The callback must be a function that takes **one** argument, which is the
343+
decoded JWT (python dictionary), and returns *`True`* if the token
344+
has been blacklisted (or is otherwise considered revoked), or *`False`*
345345
otherwise.
346346
"""
347347
self._token_in_blacklist_callback = callback
@@ -356,9 +356,9 @@ def claims_verification_loader(self, callback):
356356
:meth:`~flask_jwt_extended.JWTManager.claims_verification_failed_loader`
357357
decorator.
358358
359-
This callback must be a function that takes one argument, which is the
360-
custom claims (python dict) present in the JWT, and returns `True` if the
361-
claims are valid, or `False` otherwise.
359+
*HINT*: This callback must be a function that takes **one** argument, which is the
360+
custom claims (python dict) present in the JWT, and returns *`True`* if the
361+
claims are valid, or *`False`* otherwise.
362362
"""
363363
self._claims_verification_callback = callback
364364
return callback
@@ -372,8 +372,8 @@ def claims_verification_failed_loader(self, callback):
372372
373373
{"msg": "User claims verification failed"}
374374
375-
This callback must be a function that takes no arguments, and returns
376-
a Flask response.
375+
*HINT*: This callback must be a function that takes **no** arguments, and returns
376+
a *Flask response*.
377377
"""
378378
self._verify_claims_failed_callback = callback
379379
return callback

0 commit comments

Comments
 (0)