(js) Add support for XSRF token with downloads

Initial support to download a file from an Ajax query. This allows the
XSRF token to be sent and verified by the server.
This commit is contained in:
Francis Lachapelle
2016-05-03 12:55:58 -04:00
parent 7bf7a34a78
commit 64ce63d812
10 changed files with 81 additions and 18 deletions
+5 -6
View File
@@ -369,16 +369,15 @@
SOGoMailFolder *co;
WOResponse *response;
NSArray *uids;
NSDictionary *jsonResponse;
NSString *value;
NSDictionary *data, *jsonResponse;
co = [self clientObject];
value = [[context request] formValueForKey: @"uid"];
data = [[[context request] contentAsString] objectFromJSONString];
uids = [data objectForKey: @"uids"];
response = nil;
if ([value length] > 0)
if ([uids count] > 0)
{
uids = [value componentsSeparatedByString: @","];
response = [co archiveUIDs: uids
inArchiveNamed: [self labelForKey: @"Saved Messages.zip" inContext: context]
inContext: context];
@@ -387,7 +386,7 @@
}
else
{
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'uid' parameter." inContext: context]
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'uids' parameter." inContext: context]
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
}