Skip to content

Commit 4905faa

Browse files
committed
Merge pull request ResearchKit#128 from EricSiegNW/bug/FPHS-625
FPHS 625
2 parents cdca9d2 + 9938585 commit 4905faa

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ typedef NS_ENUM(NSInteger, APCUserConsentSharingScope) {
5858

5959
@property (nonatomic, strong, nullable) NSString * firstName DEPRECATED_ATTRIBUTE;
6060
@property (nonatomic, strong, nullable) NSString * lastName DEPRECATED_ATTRIBUTE;
61-
6261
@property (nonatomic, strong, nullable) NSString * email;
6362
@property (nonatomic, strong, nullable) NSString * password;
6463
@property (nonatomic, strong, nullable) NSString * sessionToken;
@@ -98,9 +97,6 @@ typedef NS_ENUM(NSInteger, APCUserConsentSharingScope) {
9897
@property (nonatomic, strong, nullable) NSDate *consentSignatureDate;
9998
@property (nonatomic, strong, nullable) NSData *consentSignatureImage;
10099

101-
@property (nonatomic, strong, nullable) NSDate *downloadDataStartDate; // NOT stored in CoreData
102-
@property (nonatomic, strong, nullable) NSDate *downloadDataEndDate; // NOT stored in CoreData
103-
104100
@property (nonatomic, getter=isSecondaryInfoSaved) BOOL secondaryInfoSaved;
105101

106102
/*********************************************************************************/
@@ -126,6 +122,14 @@ typedef NS_ENUM(NSInteger, APCUserConsentSharingScope) {
126122
@property (nonatomic, nullable) NSNumber * savedSharingScope;
127123
@property (nonatomic, nullable) NSArray <NSString *> * dataGroups;
128124

125+
/*********************************************************************************/
126+
#pragma mark - Stored In Memory Only
127+
/*********************************************************************************/
128+
@property (nonatomic, strong, nullable) NSString * cachedSessionToken; // Memory Only, can nil this out and sessionToken will remain safely in keychain
129+
@property (nonatomic, strong, nullable) NSDate *downloadDataStartDate; // NOT stored in CoreData
130+
@property (nonatomic, strong, nullable) NSDate *downloadDataEndDate; // NOT stored in CoreData
131+
132+
129133
- (BOOL) isLoggedOut;
130134

131135
/**

APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ -(void)setPassword:(NSString *)password
275275
[APCKeychainStore setString:[self hashIfNeeded:password] forKey:kPasswordPropertyName];
276276
}
277277

278+
- (NSString *)sessionToken
279+
{
280+
if (self.cachedSessionToken == nil) {
281+
self.cachedSessionToken = [APCKeychainStore stringForKey:kSessionTokenPropertyName];
282+
}
283+
return self.cachedSessionToken;
284+
}
285+
286+
-(void)setSessionToken:(NSString *)sessionToken
287+
{
288+
self.cachedSessionToken = sessionToken;
289+
[APCKeychainStore setString:[self hashIfNeeded:sessionToken] forKey:kSessionTokenPropertyName];
290+
}
291+
278292
- (NSString *)externalId
279293
{
280294
return [APCKeychainStore stringForKey:kExternalIdPropertyName];

APCAppCore/APCAppCore/Startup/APCAppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ - (void)applicationDidEnterBackground:(UIApplication *) __unused application
273273
[[NSUserDefaults standardUserDefaults] setObject: [NSNumber numberWithLong:uptime()] forKey:kLastUsedTimeKey];
274274
[[NSUserDefaults standardUserDefaults] synchronize];
275275
}
276-
self.dataSubstrate.currentUser.sessionToken = nil;
276+
// Clear the in memory token while preserving the keychain version
277+
self.dataSubstrate.currentUser.cachedSessionToken = nil;
277278

278279
[self showSecureView];
279280
}

0 commit comments

Comments
 (0)