Add success message

This commit is contained in:
zandercymatics 2024-05-14 15:12:39 -06:00
parent 6c823f1ade
commit 21f5c43b34
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 35 additions and 20 deletions

View file

@ -101,25 +101,9 @@ def login_callback(request):
user = authenticate(request=request, **userinfo) user = authenticate(request=request, **userinfo)
is_new_user = request.session.get("is_new_user", False) is_new_user = request.session.get("is_new_user", False)
if user: if user:
should_update_user = False # Set login metadata about this user
# Fixture users kind of exist in a superposition of verification types, # (verification_type for instance)
# because while the system "verified" them, if they login, _set_authenticated_user_metadata(user, is_new_user)
# we don't know how the user themselves was verified through login.gov until
# they actually try logging in. This edge-case only matters in non-production environments.
fixture_user = User.VerificationTypeChoices.FIXTURE_USER
is_fixture_user = user.verification_type and user.verification_type == fixture_user
# Set the verification type if it doesn't already exist or if its a fixture user
if not user.verification_type or is_fixture_user:
user.set_user_verification_type()
should_update_user = True
if is_new_user:
user.finished_setup = False
should_update_user = True
if should_update_user:
user.save()
login(request, user) login(request, user)
@ -149,6 +133,30 @@ def login_callback(request):
return error_page(request, err) return error_page(request, err)
def _set_authenticated_user_metadata(user, is_new_user):
"""Does checks on the recieved authenticated user from login_callback,
and updates fields accordingly. U"""
should_update_user = False
# Fixture users kind of exist in a superposition of verification types,
# because while the system "verified" them, if they login,
# we don't know how the user themselves was verified through login.gov until
# they actually try logging in. This edge-case only matters in non-production environments.
fixture_user = User.VerificationTypeChoices.FIXTURE_USER
is_fixture_user = user.verification_type and user.verification_type == fixture_user
# Set the verification type if it doesn't already exist or if its a fixture user
if not user.verification_type or is_fixture_user:
user.set_user_verification_type()
should_update_user = True
if is_new_user:
user.finished_setup = False
should_update_user = True
if should_update_user:
user.save()
def _requires_step_up_auth(userinfo): def _requires_step_up_auth(userinfo):
"""if User.needs_identity_verification and step_up_acr_value not in """if User.needs_identity_verification and step_up_acr_value not in
ial returned from callback, return True""" ial returned from callback, return True"""

View file

@ -2,6 +2,7 @@ from waffle.decorators import waffle_flag
from urllib.parse import urlencode, urlunparse, urlparse, quote from urllib.parse import urlencode, urlunparse, urlparse, quote
from django.urls import NoReverseMatch, reverse from django.urls import NoReverseMatch, reverse
from registrar.forms.contact import ContactForm from registrar.forms.contact import ContactForm
from django.contrib.messages.views import SuccessMessageMixin
from registrar.models.contact import Contact from registrar.models.contact import Contact
from registrar.templatetags.url_helpers import public_site_url from registrar.templatetags.url_helpers import public_site_url
from registrar.views.utility.permission_views import ContactPermissionView from registrar.views.utility.permission_views import ContactPermissionView
@ -17,10 +18,13 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class BaseContactView(ContactPermissionView): class BaseContactView(SuccessMessageMixin, ContactPermissionView):
"""Provides a base view for the contact object. On get, the contact """Provides a base view for the contact object. On get, the contact
is saved in the session and on self.object.""" is saved in the session and on self.object."""
def get_success_message(self):
return "Contact updated successfully."
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
"""Sets the current contact in cache, defines the current object as self.object """Sets the current contact in cache, defines the current object as self.object
then returns render_to_response""" then returns render_to_response"""
@ -108,6 +112,9 @@ class ContactProfileSetupView(ContactFormBaseView):
COMPLETE_SETUP = "complete_setup" COMPLETE_SETUP = "complete_setup"
TO_SPECIFIC_PAGE = "domain_request" TO_SPECIFIC_PAGE = "domain_request"
def get_success_message(self):
return "Your profile has been successfully updated."
# TODO - refactor # TODO - refactor
@waffle_flag("profile_feature") @waffle_flag("profile_feature")
@method_decorator(csrf_protect) @method_decorator(csrf_protect)