-
Notifications
You must be signed in to change notification settings - Fork 144
fix: display message magic link controller if email not send #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: display message magic link controller if email not send #204
Conversation
As usual, I forgot to run |
return $this->displayMessage(); | ||
} | ||
|
||
return redirect()->route('magic-link')->with('error', lang('Auth.unableSendEmailToUser', [$user->email])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is different from Email2FA/EmailActivator:
shield/src/Authentication/Actions/Email2FA.php
Lines 80 to 82 in c66012f
if ($return === false) { | |
throw new RuntimeException('Cannot send email for user: ' . $user->email); | |
} |
The error message is user friendly, but it seems there is no log of the mail sending failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kenjis , I really disagree with that.
I like the error message is user friendly.
Why? Just imagine yourself instead of the user.
If necessary, the site administrator should see the logs of file writable\logs.
e.g logs file:
ERROR - 2022-06-03 00:39:13 --> Email: sendWithMail throwed mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Friends, what do you think about this?
Do you agree with the following code?
if ($return === false) {
throw new RuntimeException('Cannot send email for user: ' . $user->email);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that the Email class logs properly.
Okay, this implementation has no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the code like this (the variable name) as with other classes?
$return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '')
$return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fixed issue with displaying success message if email was not sent.
The success message should not be displayed when the email is not sent to the user for any reason.