Utils
hypha.apply.users.utils
¶
get_user_by_email
¶
Source code in hypha/apply/users/utils.py
is_user_already_registered
¶
Checks if a specified user is already registered. Returns a tuple containing a boolean value that indicates if the user exists and in case he does whats the duplicated attribute
Source code in hypha/apply/users/utils.py
can_use_oauth_check
¶
Checks that the user belongs to the whitelisted domains. Anonymous or non-whitelisted email domains cannot log in or associate OAuth accounts
Source code in hypha/apply/users/utils.py
send_activation_email
¶
send_activation_email(user, site=None, email_template='users/activation/email.txt', email_subject_template='users/activation/email_subject.txt', redirect_url='')
Send the activation email. The activation key is the username, signed using TimestampSigner.
Source code in hypha/apply/users/utils.py
send_confirmation_email
¶
Send the confirmation email. The confirmation token is the update email, signed using TimestampSigner.
Source code in hypha/apply/users/utils.py
get_redirect_url
¶
Return the user-originating redirect URL if it's safe.
Parameters:
-
request(HttpRequest) –The request object.
-
redirect_field(str) –The name of a field containing the redirect URL.
-
success_url_allowed_hosts(set, default:None) –A set of allowed hosts for the redirect URL.
Source code in hypha/apply/users/utils.py
generate_numeric_token
¶
Generate a random 6 digit string of numbers. We use this formatting to allow leading 0s.
login_ratelimit_key
¶
Per-account rate-limit key for the two-factor login wizard.
The wizard prefixes its fields, so the account identifier arrives as
auth-username, not email. The later steps (OTP, backup token) post no
username at all, and neither do the passwordless views that share this
decorated dispatch — those fall back to the client IP.
Never return a constant for the missing-field case: django-ratelimit hashes whatever it is given, so every such request would land in a single bucket and any one client could exhaust login for everybody.
Source code in hypha/apply/users/utils.py
update_is_staff
¶
Determine if the user should have is_staff
Django Admin is the only use for is_staff
Parameters:
-
request–The edit request object (unused)
-
user–Userto modify
Source code in hypha/apply/users/utils.py
get_zoneinfo
¶
Return a ZoneInfo for tz_name, or None if invalid/empty.
local_event_time
¶
Return a human-readable "now", localised to the user's timezone.
Shared by the account-security notification emails (login, passkey added/removed) so the timestamp line reads the same across them.
Source code in hypha/apply/users/utils.py
passkeys_enabled
¶
Passkeys require WEBAUTHN_RP_ID in production. In DEBUG (local/dev) we fall back to the request host so the feature can be exercised locally.