only send messages for stuff non-redirecting
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
@ -193,8 +193,9 @@ class ChallengeStageView(StageView):
|
||||
)
|
||||
flow_info.is_valid()
|
||||
challenge.initial_data["flow_info"] = flow_info.data
|
||||
# TODO: only do it for non-redirect challenges
|
||||
if "messages" not in challenge.initial_data:
|
||||
if "messages" not in challenge.initial_data and not isinstance(
|
||||
challenge, RedirectStage
|
||||
):
|
||||
messages = MessageSerializer(
|
||||
data=[
|
||||
{
|
||||
|
@ -96,7 +96,6 @@ class OAuthCallback(OAuthClientMixin, View):
|
||||
def handle_login_failure(self, reason: str) -> HttpResponse:
|
||||
"Message user and redirect on error."
|
||||
LOGGER.warning("Authentication Failure", reason=reason)
|
||||
# TODO(risson): figure out how to avoid this
|
||||
messages.error(
|
||||
self.request,
|
||||
_(
|
||||
|
@ -139,7 +139,6 @@ class EmailStageView(ChallengeStageView):
|
||||
if restore_token.user != user:
|
||||
self.logger.warning("Flow token for non-matching user, denying request")
|
||||
return self.executor.stage_invalid()
|
||||
# TODO(risson): figure out how to avoid this
|
||||
messages.success(request, _("Successfully verified Email."))
|
||||
if self.executor.current_stage.activate_user_on_success:
|
||||
user.is_active = True
|
||||
@ -172,11 +171,9 @@ class EmailStageView(ChallengeStageView):
|
||||
|
||||
def challenge_invalid(self, response: ChallengeResponse) -> HttpResponse:
|
||||
if PLAN_CONTEXT_PENDING_USER not in self.executor.plan.context:
|
||||
# TODO(risson): figure out how to avoid this
|
||||
messages.error(self.request, _("No pending user."))
|
||||
return super().challenge_invalid(response)
|
||||
self.send_email()
|
||||
# TODO(risson): figure out how to avoid this
|
||||
messages.success(self.request, _("Email Successfully sent."))
|
||||
# We can't call stage_ok yet, as we're still waiting
|
||||
# for the user to click the link in the email
|
||||
|
@ -150,7 +150,6 @@ class PromptChallengeResponse(ChallengeResponse):
|
||||
raise ValidationError(list(result.messages))
|
||||
else:
|
||||
for msg in result.messages:
|
||||
# TODO(risson): figure out how to avoid this
|
||||
add_message(self.request, INFO, msg)
|
||||
return attrs
|
||||
|
||||
|
Reference in New Issue
Block a user