Skip to content

Commit 100cfac

Browse files
Copilotnijel
andcommitted
Address code review feedback: use Sphinx directives and remove duplication
Co-authored-by: nijel <[email protected]>
1 parent 0572aa4 commit 100cfac

File tree

1 file changed

+18
-46
lines changed

1 file changed

+18
-46
lines changed

docs/pipeline.rst

Lines changed: 18 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Pipeline functions can return three types of values, each with different behavio
5050
# Interrupt pipeline and redirect user
5151
return redirect('/some-form/')
5252

53+
.. _common-function-parameters:
54+
5355
Common Function Parameters
5456
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5557

@@ -167,8 +169,10 @@ A pipeline that won't create users, just accepts already registered ones would l
167169
'social_core.pipeline.user.user_details',
168170
)
169171

170-
**Note:** This example removes ``get_username`` and ``create_user`` steps, so only
171-
users who have previously authenticated can log in.
172+
.. note::
173+
174+
This example removes ``get_username`` and ``create_user`` steps, so only
175+
users who have previously authenticated can log in.
172176

173177
**Example 2: Custom User Loading**
174178

@@ -279,7 +283,9 @@ Here's a simple example of collecting additional user information::
279283
# No email yet - interrupt pipeline and show form
280284
return strategy.render_html('email_form.html')
281285

282-
In your template, the form should POST to ``/complete/<backend>/``::
286+
In your template, the form should POST to ``/complete/<backend>/``.
287+
288+
**Django example**::
283289

284290
<form method="post" action="{% url 'social:complete' backend %}">
285291
{% csrf_token %}
@@ -409,9 +415,11 @@ Steps to Add a Custom Pipeline Function
409415
2. **Place it in an importable location** in your project
410416
3. **Add it to the pipeline** in your settings at the appropriate position
411417

412-
**Important:** Function placement matters! The order determines what data is available.
413-
For example, placing your function after ``create_user`` ensures you receive a ``user``
414-
instance rather than ``None``.
418+
.. important::
419+
420+
Function placement matters! The order determines what data is available.
421+
For example, placing your function after ``create_user`` ensures you receive a ``user``
422+
instance rather than ``None``.
415423

416424
Writing Custom Pipeline Functions
417425
----------------------------------
@@ -425,48 +433,12 @@ Your function should accept the common parameters and ``**kwargs``::
425433
# Your code here
426434
pass
427435

428-
**Tip:** Always include ``**kwargs`` to handle additional parameters from other
429-
pipeline functions or future versions.
430-
431-
Common Parameters Available
432-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
433-
434-
Depending on where you place your function in the pipeline, these parameters may be available:
435-
436-
``strategy``
437-
The current strategy instance.
438-
439-
``backend``
440-
The current backend instance.
441-
442-
``uid``
443-
User ID in the provider, this ``uid`` should identify the user in the
444-
current provider.
445-
446-
``response = {} or object()``
447-
The server user-details response, it depends on the protocol in use (and
448-
sometimes the provider implementation of such protocol), but usually it's
449-
just a ``dict`` with the user profile details from the provider. Lots of
450-
information related to the user is provided here, sometimes the ``scope``
451-
will increase the amount of information in this response on OAuth
452-
providers.
453-
454-
``details = {}``
455-
Basic user details generated by the backend, used to create/update the user
456-
model details (this ``dict`` will contain values like ``username``,
457-
``email``, ``first_name``, ``last_name`` and ``fullname``).
458-
459-
``user = None``
460-
The user instance (or ``None`` if not yet created or retrieved).
461-
462-
``social = None``
463-
The ``UserSocialAuth`` instance for the user (or ``None`` if not yet created).
436+
.. tip::
464437

465-
``is_new``
466-
Boolean flag indicating if the user was just created (``True``) or already existed (``False``).
438+
Always include ``**kwargs`` to handle additional parameters from other
439+
pipeline functions or future versions.
467440

468-
``request``
469-
The current HTTP request object.
441+
See :ref:`common-function-parameters` for details on the parameters available to pipeline functions.
470442

471443
Practical Example: Saving User Profile Data
472444
--------------------------------------------

0 commit comments

Comments
 (0)