fix(pwd): use the proper url for reset password mail part2

This commit is contained in:
Hivert Quentin
2026-09-08 17:29:05 +02:00
parent 382118a93b
commit a4cf153387
4 changed files with 32 additions and 4 deletions
+10 -1
View File
@@ -34,6 +34,7 @@ main (int argc, char **argv, char **env)
{
NSAutoreleasePool *pool;
SOGoSystemDefaults *sd;
NSArray *baseUrls;
int rc;
/* Here we work around a bug in GNUstep which decode XML user defaults using
@@ -54,7 +55,15 @@ main (int argc, char **argv, char **env)
rc =-1;
NSLog (@"Sogo secret is not correctly set");
}
else
//Check sogo base urls
if(!((baseUrls = [sd baseURLs]) && [baseUrls count] > 0))
{
rc = -1;
NSLog (@"SOGoBaseUrls is not set or empty");
}
if(rc == 0)
{
WOWatchDogApplicationMain (@"SOGo", argc, (void *) argv);
}
+1
View File
@@ -57,6 +57,7 @@ static const NSString *kDisableSharingCalendar = @"Calendar";
- (NSString *) sogoSecretValue;
- (BOOL) useRelativeURLs;
- (NSString *) sieveFolderEncoding;
- (NSArray *) baseURLs;
- (BOOL) isWebAccessEnabled;
- (BOOL) isCalendarDAVAccessEnabled;
+6
View File
@@ -724,6 +724,12 @@ NSComparisonResult languageSort(id el1, id el2, void *context)
return [self stringForKey: @"SOGoLoginSuffix"];
}
- (NSArray *) baseURLs
{
return [self stringArrayForKey: @"SOGoBaseUrls"];
}
- (NSString *) authenticationType
{
return [[self stringForKey: @"SOGoAuthenticationType"] lowercaseString];
+15 -3
View File
@@ -1316,7 +1316,8 @@ static const NSString *kJwtKey = @"jwt";
*/
- (WOResponse *) passwordRecoveryEmailAction
{
NSString *username, *domain, *mode, *uid, *mailDomain, *fromEmail, *toEmail, *jwtToken, *url, *mailContent, *email;
NSString *username, *domain, *mode, *uid, *mailDomain, *fromEmail, *toEmail, *jwtToken, *url, *mailContent, *email, *serverUrl;
NSArray *baseUrls;
NSDictionary *message, *info;
WORequest *request;
SOGoUserManager *um;
@@ -1372,8 +1373,19 @@ static const NSString *kJwtKey = @"jwt";
// Send mail
mailer = [SOGoMailer mailerWithDomainDefaults: dd];
url = [NSString stringWithFormat:@"%@/%@?token=%@"
, [[context serverURL] absoluteString]
//Get Allowed server URL and check if it's OK
baseUrls = [[SOGoSystemDefaults sharedSystemDefaults] baseURLs];
serverUrl = [[request headers] objectForKey:@"origin"];
if(![baseUrls containsObject:serverUrl])
{
[self logWithFormat: @"Password recovery exception for user %@: invalid request header", uid];
response = [self responseWithStatus: 403
andString: @"Password recovery email in error"];
}
url = [NSString stringWithFormat:@"%@%@?token=%@"
, serverUrl
, [request uri]
, jwtToken];