Showing
2 changed files
with
44 additions
and
1 deletions
| ... | @@ -76,6 +76,8 @@ extern NSString* VERIFY_URL; | ... | @@ -76,6 +76,8 @@ extern NSString* VERIFY_URL; |
| 76 | #define WL_DEVICE_STATUS @"device_status" | 76 | #define WL_DEVICE_STATUS @"device_status" |
| 77 | #define WL_BEACON_ENABLED @"BEACON_ENABLED" | 77 | #define WL_BEACON_ENABLED @"BEACON_ENABLED" |
| 78 | #define WL_BEACON_TIME_INTERVAL_TO_RESEND @"BEACON_TIME_INTERVAL_TO_RESEND" | 78 | #define WL_BEACON_TIME_INTERVAL_TO_RESEND @"BEACON_TIME_INTERVAL_TO_RESEND" |
| 79 | +#define WL_AUTHENTICATION @"AUTHENTICATION" | ||
| 80 | +#define WL_IS_JWT_ENABLED @"isJWTEnabled" | ||
| 79 | 81 | ||
| 80 | /////////////////////////////////////////////////////////////////////////////// | 82 | /////////////////////////////////////////////////////////////////////////////// |
| 81 | // Logging | 83 | // Logging | ... | ... |
| ... | @@ -290,6 +290,9 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * | ... | @@ -290,6 +290,9 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * |
| 290 | _pendingOperationsQueue.maxConcurrentOperationCount = 1; | 290 | _pendingOperationsQueue.maxConcurrentOperationCount = 1; |
| 291 | 291 | ||
| 292 | _DatabaseLock = @"Database-Lock"; | 292 | _DatabaseLock = @"Database-Lock"; |
| 293 | + | ||
| 294 | + // Get Application Data | ||
| 295 | + [self getAppSettingsWithSuccessBlock:^{} failureBlock:^(NSError *error) {}]; | ||
| 293 | } | 296 | } |
| 294 | return self; | 297 | return self; |
| 295 | } | 298 | } |
| ... | @@ -1199,8 +1202,12 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1199,8 +1202,12 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
| 1199 | if (tableExist == YES) { | 1202 | if (tableExist == YES) { |
| 1200 | NSString *accessToken = @""; | 1203 | NSString *accessToken = @""; |
| 1201 | NSString *refreshToken = @""; | 1204 | NSString *refreshToken = @""; |
| 1205 | + NSString *clientId = @""; | ||
| 1206 | + NSString *clientSecret = @""; | ||
| 1202 | accessToken = [_sharedService getAccessToken2]; | 1207 | accessToken = [_sharedService getAccessToken2]; |
| 1203 | refreshToken = [_sharedService getRefreshToken]; | 1208 | refreshToken = [_sharedService getRefreshToken]; |
| 1209 | + clientId = [_sharedService getClientId]; | ||
| 1210 | + clientSecret = [_sharedService getClientSecret]; | ||
| 1204 | 1211 | ||
| 1205 | 1212 | ||
| 1206 | NSMutableDictionary* data = [[NSMutableDictionary alloc] init]; | 1213 | NSMutableDictionary* data = [[NSMutableDictionary alloc] init]; |
| ... | @@ -1208,6 +1215,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1208,6 +1215,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
| 1208 | [data setValue:accessToken forKey:@"access_token"]; | 1215 | [data setValue:accessToken forKey:@"access_token"]; |
| 1209 | [data setValue:refreshToken forKey:@"refresh_token"]; | 1216 | [data setValue:refreshToken forKey:@"refresh_token"]; |
| 1210 | 1217 | ||
| 1218 | + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||
| 1219 | + BOOL isJWTEnabled = [defaults boolForKey:WL_IS_JWT_ENABLED]; | ||
| 1220 | + if (isJWTEnabled) { | ||
| 1221 | + [data setValue:accessToken forKey:@"access_token"]; | ||
| 1222 | + [data setValue:refreshToken forKey:@"refresh_token"]; | ||
| 1223 | + } else { | ||
| 1224 | + [data setValue:accessToken forKey:@"token"]; | ||
| 1225 | + [data setValue:clientId forKey:@"client_id"]; | ||
| 1226 | + [data setValue:clientSecret forKey:@"client_secret"]; | ||
| 1227 | + } | ||
| 1228 | + | ||
| 1211 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:NULL]; | 1229 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:NULL]; |
| 1212 | [self sendContextLogout:jsonData successBlock:^(NSDictionary *contextResponse) { | 1230 | [self sendContextLogout:jsonData successBlock:^(NSDictionary *contextResponse) { |
| 1213 | if (success) { | 1231 | if (success) { |
| ... | @@ -6926,7 +6944,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6926,7 +6944,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
| 6926 | { | 6944 | { |
| 6927 | //Create REQUEST | 6945 | //Create REQUEST |
| 6928 | // POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout | 6946 | // POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout |
| 6929 | - NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | 6947 | +// NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; |
| 6948 | + | ||
| 6949 | + NSMutableString *urlString = [NSMutableString string]; | ||
| 6950 | + | ||
| 6951 | + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||
| 6952 | + BOOL isJWTEnabled = [defaults boolForKey:WL_IS_JWT_ENABLED]; | ||
| 6953 | + if (isJWTEnabled) { | ||
| 6954 | +// /user/v5/{appUuid}/logout | ||
| 6955 | + urlString = [NSMutableString stringWithFormat:@"%@/user/v5/%@/logout", _baseURL, _appUUID]; | ||
| 6956 | + } else { | ||
| 6957 | + urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | ||
| 6958 | + } | ||
| 6930 | 6959 | ||
| 6931 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | 6960 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); |
| 6932 | 6961 | ||
| ... | @@ -8196,6 +8225,18 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg | ... | @@ -8196,6 +8225,18 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg |
| 8196 | NSLog(@"Beacon scanning is disabled"); | 8225 | NSLog(@"Beacon scanning is disabled"); |
| 8197 | } | 8226 | } |
| 8198 | 8227 | ||
| 8228 | + if ([applicationVariables objectForKey:WL_AUTHENTICATION]) { | ||
| 8229 | + NSString *authValue = [applicationVariables objectForKey:WL_AUTHENTICATION]; | ||
| 8230 | + if (authValue && [authValue isEqualToString:@"JWT"]) { | ||
| 8231 | + // AUTHENTICATION key exists and its value is "JWT" | ||
| 8232 | + [defaults setBool:YES forKey:WL_IS_JWT_ENABLED]; | ||
| 8233 | + } else { | ||
| 8234 | + [defaults setBool:NO forKey:WL_IS_JWT_ENABLED]; | ||
| 8235 | + } | ||
| 8236 | + } else { | ||
| 8237 | + [defaults setBool:NO forKey:WL_IS_JWT_ENABLED]; | ||
| 8238 | + } | ||
| 8239 | + | ||
| 8199 | [defaults setObject:[NSDate date] forKey:@"lastFeaturesUpdateTimestamp"]; | 8240 | [defaults setObject:[NSDate date] forKey:@"lastFeaturesUpdateTimestamp"]; |
| 8200 | 8241 | ||
| 8201 | //Check for device status | 8242 | //Check for device status | ... | ... |
-
Please register or login to post a comment