mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-27 14:16:02 +00:00
feat: support password change well-known (#12878)
as per https://adamj.eu/tech/2026/09/16/django-change-password-url/
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""Base plugin which defines the built-in well-known entries."""
|
"""Base plugin which defines the built-in well-known entries."""
|
||||||
|
|
||||||
from django.http import HttpRequest, JsonResponse
|
from django.http import HttpRequest, JsonResponse
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.urls import path, reverse_lazy
|
from django.urls import path, reverse_lazy
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@@ -42,6 +43,17 @@ class InvenTreeWellKnown(WellKnownMixin, UrlsMixin, InvenTreePlugin):
|
|||||||
# If the flag is not evaluated successfully, we can ignore it
|
# If the flag is not evaluated successfully, we can ignore it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# change password to help pwd managers - see https://adamj.eu/tech/2026/09/16/django-change-password-url/
|
||||||
|
data.append((
|
||||||
|
'change-password',
|
||||||
|
reverse_lazy(f'plugin:{self.slug}:change-password'),
|
||||||
|
))
|
||||||
|
# dead url (for change-password)
|
||||||
|
data.append((
|
||||||
|
'resource-that-should-not-exist-whose-status-code-should-not-be-200',
|
||||||
|
reverse_lazy(f'plugin:{self.slug}:dead'),
|
||||||
|
))
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@auth_exempt
|
@auth_exempt
|
||||||
@@ -52,6 +64,22 @@ class InvenTreeWellKnown(WellKnownMixin, UrlsMixin, InvenTreePlugin):
|
|||||||
)
|
)
|
||||||
return JsonResponse({'enroll': passkey_web, 'manage': passkey_web})
|
return JsonResponse({'enroll': passkey_web, 'manage': passkey_web})
|
||||||
|
|
||||||
|
@auth_exempt
|
||||||
|
def view_change_password(self, request, *args, **kwargs):
|
||||||
|
"""Redirect to the change-password web page."""
|
||||||
|
return redirect(
|
||||||
|
request.build_absolute_uri(InvenTree.helpers.pui_url('/change-password'))
|
||||||
|
)
|
||||||
|
|
||||||
|
@auth_exempt
|
||||||
|
def view_dead(self, request, *args, **kwargs):
|
||||||
|
"""Return a 404 for the dead well-known entry."""
|
||||||
|
return JsonResponse({'error': 'Not found'}, status=404)
|
||||||
|
|
||||||
def setup_urls(self):
|
def setup_urls(self):
|
||||||
"""Urls that are exposed by this plugin."""
|
"""Urls that are exposed by this plugin."""
|
||||||
return [path('passkey/', self.view_passkey, name='passkey')]
|
return [
|
||||||
|
path('passkey/', self.view_passkey, name='passkey'),
|
||||||
|
path('change-password', self.view_change_password, name='change-password'),
|
||||||
|
path('dead', self.view_dead, name='dead'),
|
||||||
|
]
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export default function Set_Password() {
|
|||||||
label={t`Current Password`}
|
label={t`Current Password`}
|
||||||
description={t`Enter your current password`}
|
description={t`Enter your current password`}
|
||||||
{...simpleForm.getInputProps('current_password')}
|
{...simpleForm.getInputProps('current_password')}
|
||||||
|
autoComplete='current-password'
|
||||||
/>
|
/>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
required
|
required
|
||||||
@@ -53,6 +54,7 @@ export default function Set_Password() {
|
|||||||
label={t`New Password`}
|
label={t`New Password`}
|
||||||
description={t`Enter your new password`}
|
description={t`Enter your new password`}
|
||||||
{...simpleForm.getInputProps('new_password1')}
|
{...simpleForm.getInputProps('new_password1')}
|
||||||
|
autoComplete='new-password'
|
||||||
/>
|
/>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
required
|
required
|
||||||
|
|||||||
Reference in New Issue
Block a user