mirror of https://github.com/oxen-io/session-ios
Generate new registrationId on re-register
In order for others to know they should start a new session with us, we need to change our registration id. To achieve this, I consolidated all the Account related attributes on TSAccountManager - luckily they were already in the proper collection, I just moved the API to hang on the AccountManager instead of a TSStorage category extension. Also: @synchronize access to `registrationId` // FREEBIEpull/1/head
parent
58d4c95362
commit
0706edf42a
@ -1,29 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSStorageManager.h"
|
||||
|
||||
@interface TSStorageManager (keyingMaterial)
|
||||
|
||||
#pragma mark Server Credentials
|
||||
|
||||
/**
|
||||
* The server signaling key that's used to encrypt push payloads
|
||||
*
|
||||
* @return signaling key
|
||||
*/
|
||||
|
||||
+ (NSString *)signalingKey;
|
||||
|
||||
/**
|
||||
* The server auth token allows the TextSecure client to connect to the server
|
||||
*
|
||||
* @return server authentication token
|
||||
*/
|
||||
|
||||
+ (NSString *)serverAuthToken;
|
||||
|
||||
+ (void)storeServerToken:(NSString *)authToken signalingKey:(NSString *)signalingKey;
|
||||
|
||||
@end
|
@ -1,41 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSStorageManager+keyingMaterial.h"
|
||||
|
||||
// TODO merge this category extension's functionality into TSAccountManager
|
||||
@implementation TSStorageManager (keyingMaterial)
|
||||
|
||||
+ (NSString *)signalingKey {
|
||||
return [[self sharedManager] stringForKey:TSStorageServerSignalingKey inCollection:TSStorageUserAccountCollection];
|
||||
}
|
||||
|
||||
+ (NSString *)serverAuthToken {
|
||||
return [[self sharedManager] stringForKey:TSStorageServerAuthToken inCollection:TSStorageUserAccountCollection];
|
||||
}
|
||||
|
||||
+ (void)storeServerToken:(NSString *)authToken signalingKey:(NSString *)signalingKey {
|
||||
TSStorageManager *sharedManager = self.sharedManager;
|
||||
[sharedManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[transaction setObject:authToken forKey:TSStorageServerAuthToken inCollection:TSStorageUserAccountCollection];
|
||||
[transaction setObject:signalingKey
|
||||
forKey:TSStorageServerSignalingKey
|
||||
inCollection:TSStorageUserAccountCollection];
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)logTag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)logTag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue