mojio/mojio-ios-sdk

Function logoutWithCompletionBlock of MojioClient erases whole NSUserDefaults

Vratislav opened this issue · 0 comments

This particular function in MojioClient erases everything stored in NSUserDefaults:

- (void)logoutWithCompletionBlock:(void (^)(void))completionBlock {
    [[self.manager requestSerializer] setValue:nil forHTTPHeaderField:@"MojioAPIToken"];

    // remove all objects from the NSUserDefaults
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *defaultsDict = [defaults dictionaryRepresentation];
    for (id key in defaultsDict) {
        [defaults removeObjectForKey:key];
    }
    [defaults synchronize];

    if (completionBlock) {
        completionBlock();
    }
}

This is not wise. You should probably only erase values stored by your SDK. Current implementation erases any other possible values stored by other parties.