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