---
url: "https://vueda.dev/v3/reference/api/py/vueda.core.reauthentication.md"
title: "core.reauthentication"
---

# core.reauthentication

## Overview

Reauthentication policy: which flow a user must complete, and whether their session completed it recently.

## `did_recently_authenticate` {#did_recently_authenticate}

Return whether the session holds an authentication record for the user's required flow that is newer
than ``ACCOUNT_REAUTHENTICATION_TIMEOUT``.

Login and reauthentication both write records, so a fresh login satisfies the check as well as a
reauthentication does. Only records of the required method count: confirming the password does not
refresh the session of a user who must confirm a second factor.

### Signature {#did_recently_authenticate-signature}

`did_recently_authenticate(request)`

#### Parameters {#did_recently_authenticate-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="did_recently_authenticate-param-request">request</span> |  | yes |  |  |

### Source {#did_recently_authenticate-source}

`server/vueda/core/reauthentication.py:38`

## `required_flow` {#required_flow}

Return the allauth ``Flow`` the user must complete to count as recently authenticated.

A user with an MFA authenticator confirms a second factor (``Flow.MFA_REAUTHENTICATE``). A user with only
a usable password confirms the password (``Flow.REAUTHENTICATE``). A user with neither has nothing to
confirm, so the result is ``None`` and the session always counts as recent.

### Signature {#required_flow-signature}

`required_flow(user)`

#### Parameters {#required_flow-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="required_flow-param-user">user</span> |  | yes |  |  |

### Source {#required_flow-source}

`server/vueda/core/reauthentication.py:21`

## `RECORD_METHOD_BY_FLOW` {#RECORD_METHOD_BY_FLOW}

The ``method`` allauth writes into a session authentication record when each flow completes.

## Source

`server/vueda/core/reauthentication.py`
