Skip to content
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

First email notification link wrong #33754

Closed
fpamelard opened this issue Aug 30, 2022 · 6 comments · Fixed by #39607
Closed

First email notification link wrong #33754

fpamelard opened this issue Aug 30, 2022 · 6 comments · Fixed by #39607
Labels

Comments

@fpamelard
Copy link

Dear NextCloud team,

We've got a NextCloud instance into a subdomain mysub.mydomain.com. I've checked the config.php and everything seems good.
However, the first email for a new member refers to a link with mysub..mydomain.com (double dots).

Is there a way to fix it?

Regards,
Fabien

@nickvergessen
Copy link
Member

Can you post the content or a screenshot of the email (domain is not needed) so we can know where to look at?

@fpamelard
Copy link
Author

Here is

Capture d’écran 2022-08-30 145740

@nickvergessen nickvergessen transferred this issue from nextcloud/announcementcenter Aug 30, 2022
@nickvergessen
Copy link
Member

Email in question:

public function generateTemplate(IUser $user, $generatePasswordResetToken = false) {
$userId = $user->getUID();
$lang = $this->l10nFactory->getUserLanguage($user);
$l10n = $this->l10nFactory->get('settings', $lang);
if ($generatePasswordResetToken) {
$token = $this->secureRandom->generate(
21,
ISecureRandom::CHAR_ALPHANUMERIC
);
$tokenValue = $this->timeFactory->getTime() . ':' . $token;
$mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : '';
$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret'));
$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]);
} else {
$link = $this->urlGenerator->getAbsoluteURL('/');
}
$displayName = $user->getDisplayName();
$emailTemplate = $this->mailer->createEMailTemplate('settings.Welcome', [
'link' => $link,
'displayname' => $displayName,
'userid' => $userId,
'instancename' => $this->themingDefaults->getName(),
'resetTokenGenerated' => $generatePasswordResetToken,
]);
$emailTemplate->setSubject($l10n->t('Your %s account was created', [$this->themingDefaults->getName()]));
$emailTemplate->addHeader();
if ($displayName === $userId) {
$emailTemplate->addHeading($l10n->t('Welcome aboard'));
} else {
$emailTemplate->addHeading($l10n->t('Welcome aboard %s', [$displayName]));
}
$emailTemplate->addBodyText($l10n->t('Welcome to your %s account, you can add, protect, and share your data.', [$this->themingDefaults->getName()]));
if ($user->getBackendClassName() !== 'LDAP') {
$emailTemplate->addBodyText($l10n->t('Your username is: %s', [$userId]));
}
if ($generatePasswordResetToken) {
$leftButtonText = $l10n->t('Set your password');
} else {
$leftButtonText = $l10n->t('Go to %s', [$this->themingDefaults->getName()]);
}
$clientDownload = $this->config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients');
if ($clientDownload === '') {
$emailTemplate->addBodyButton(
$leftButtonText,
$link
);
} else {
$emailTemplate->addBodyButtonGroup(
$leftButtonText,
$link,
$l10n->t('Install Client'),
$clientDownload
);
}
$emailTemplate->addFooter('', $lang);
return $emailTemplate;
}

@fpamelard
Copy link
Author

Yes, but seems there is an issue with the absoluteURL

image

@joshtrichards
Copy link
Member

Hi @fpamelard - Can you provide your config (i.e. output of ./occ config:list system) so we can try to reproduce this?

Since your issue was created in a different repo initially it may have bypassed the normal bug report form. Some other bits of info might be useful too (you can see what's normally requested here: https://github.com/nextcloud/server/issues/new/choose), but your basic config may turn out to be sufficient.

@joshtrichards
Copy link
Member

If willing, test PR #39607 to see if it fixes your situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants