diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 4d91b7435..12bec8609 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -808,6 +808,9 @@ specified as an array of dictionaries. |S |SOGoPasswordRecoveryDomains |List of domains where password recovery is enabled, for example `(example.org, example.net)`. If empty array `()`, disabled for all domains. If not set, enabled for all domains. +|D |SOGoPasswordRecoveryFrom +|From email when `SOGoPasswordRecoverySecondaryEmail` is set and no user domain is defined - otherwise it will use noreply@foo.bar where foo.bar is the selected user domain. Default value is `noreply@domain.com`. + |U |SOGoPasswordRecoveryMode |User password recovery mode. Values can be `Disabled`, `SecretQuestion` or `SecondaryEmail`. diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index cd9f8b929..0c74e12db 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -99,6 +99,8 @@ - (BOOL) createIdentitiesDisabled; +- (NSString *) passwordRecoveryFrom; + @end #endif /* SOGODOMAINDEFAULTS_H */ diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index d508905c7..4eacf1803 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -448,4 +448,16 @@ return [self boolForKey: @"SOGoCreateIdentitiesDisabled"]; } +- (NSString *) passwordRecoveryFrom +{ + NSString *emailFrom; + + emailFrom = [self stringForKey: @"SOGoPasswordRecoveryFrom"]; + + if (!emailFrom) + emailFrom = @"noreply@domain.com"; // Default email from when no domain set + + return emailFrom; +} + @end diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 237abbfc9..efdc6fe82 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -869,11 +869,18 @@ static const NSString *kJwtKey = @"jwt"; if (!mode && jwtToken) { response = [self _standardDefaultAction]; } else if ([mode isEqualToString: SOGoPasswordRecoverySecondaryEmail]) { - if (mailDomain && username) { + if (username) { + ownerUser = [SOGoUser userWithLogin: username]; + dd = [ownerUser domainDefaults]; + // Email recovery // Create email from - fromEmail = [NSString stringWithFormat:@"noreply@%@", mailDomain]; + if (mailDomain) { + fromEmail = [NSString stringWithFormat:@"noreply@%@", mailDomain]; + } else { + fromEmail = [dd passwordRecoveryFrom]; + } // Get password recovery email info = [um contactInfosForUserWithUIDorEmail: username]; @@ -887,8 +894,6 @@ static const NSString *kJwtKey = @"jwt"; jwtToken = [um generateAndSavePasswordRecoveryTokenWithUid: uid username: username domain: domain]; // Send mail - ownerUser = [SOGoUser userWithLogin: username]; - dd = [ownerUser domainDefaults]; mailer = [SOGoMailer mailerWithDomainDefaults: dd]; url = [NSString stringWithFormat:@"%@%@?token=%@" , [[request headers] objectForKey:@"origin"] @@ -922,7 +927,7 @@ static const NSString *kJwtKey = @"jwt"; andString: @"Invalid configuration for email password recovery"]; } } else { - [self logWithFormat: @"No user domain found for password recovery"]; + [self logWithFormat: @"No user found for password recovery"]; response = [self responseWithStatus: 403 andString: @"Invalid configuration for email password recovery"]; }