else: logger.info('pushing attributes of %s to %s', self.request.user, sp_id) def form_valid(self, form): if settings.PUSH_PROFILE_UPDATES: thread.start_new_thread(self.push_attributes, ()) return super(EditProfile, self).form_valid(form) def get_form_kwargs(self, **kwargs): kwargs = super(EditProfile, self).get_form_kwargs(**kwargs) kwargs['prefix'] = 'edit-profile' return kwargs edit_profile = prevent_access_to_transient_users(EditProfile.as_view()) def su(request, username, redirect_url='/'): '''To use this view add: url(r'^su/(?P<username>.*)/$', 'authentic2.views.su', {'redirect_url': '/'}), ''' if request.user.is_superuser or request.session.get('has_superuser_power'): su_user = shortcuts.get_object_or_404(get_user_model(), username=username) if su_user.is_active: request.session[SESSION_KEY] = su_user.id request.session['has_superuser_power'] = True return http.HttpResponseRedirect(redirect_url) else: return http.HttpResponseRedirect('/')
urlpatterns = patterns('', (r'^$', login_required(authentic2.idp.views.homepage), {}, 'index')) not_homepage_patterns = patterns('', url(r'^', include('authentic2.auth2_auth.urls')), url(r'^redirect/(.*)', 'authentic2.views.redirect'), url(r'^accounts/', include(app_settings.A2_REGISTRATION_URLCONF)), url(r'^admin/', include(admin.site.urls)), url(r'^admin_tools/', include('admin_tools.urls')), url(r'^idp/', include('authentic2.idp.urls')), url(r'^logout/$', 'authentic2.idp.views.logout', name='auth_logout'), url(r'^profile/edit/$', 'authentic2.views.edit_profile', name='profile_edit'), url(r'^profile/$', prevent_access_to_transient_users(authentic2.idp.views.profile), {}, 'account_management'), ) urlpatterns += not_homepage_patterns urlpatterns += patterns('', (r'^authsaml2/', include('authentic2.authsaml2.urls')), ) if getattr(settings, 'IDP_OPENID', False): urlpatterns += patterns('', (r'^openid/', include('authentic2.idp.idp_openid.urls'))) if 'authentic2.auth2_auth.auth2_oath' in settings.INSTALLED_APPS: urlpatterns += patterns('',