allow redirect /accounts/ to an external page (fixes #21770)
New setting is A2_ACCOUNTS_URL.
This commit is contained in:
parent
740b0ad4b2
commit
666d016b91
|
@ -190,6 +190,7 @@ default_settings = dict(
|
|||
A2_SET_RANDOM_PASSWORD_ON_RESET=Setting(
|
||||
default=True,
|
||||
definition='Set a random password on request to reset the password from the front-office'),
|
||||
A2_ACCOUNTS_URL=Setting(default=None, definition='IdP has no account page, redirect to this one.'),
|
||||
)
|
||||
|
||||
app_settings = AppSettings(default_settings)
|
||||
|
|
|
@ -370,6 +370,11 @@ homepage = Homepage.as_view()
|
|||
class ProfileView(cbv.TemplateNamesMixin, TemplateView):
|
||||
template_names = ['idp/account_management.html', 'authentic2/accounts.html']
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if app_settings.A2_ACCOUNTS_URL:
|
||||
return utils.redirect(request, app_settings.A2_ACCOUNTS_URL)
|
||||
return super(ProfileView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super(ProfileView, self).get_context_data(**kwargs)
|
||||
frontends = utils.get_backends('AUTH_FRONTENDS')
|
||||
|
|
|
@ -35,3 +35,12 @@ def test_account_delete(app, simple_user):
|
|||
|
||||
def test_login_invalid_next(app):
|
||||
app.get(reverse('auth_login') + '?next=plop')
|
||||
|
||||
|
||||
def test_custom_account(settings, app, simple_user):
|
||||
response = login(app, simple_user, path=reverse('account_management'))
|
||||
assert response.status_code == 200
|
||||
settings.A2_ACCOUNTS_URL = 'http://combo/account/'
|
||||
response = app.get(reverse('account_management'))
|
||||
assert response.status_code == 302
|
||||
assert response['Location'] == settings.A2_ACCOUNTS_URL
|
||||
|
|
Loading…
Reference in New Issue