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) { |
... | @@ -6993,7 +7011,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6993,7 +7011,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6993 | { | 7011 | { |
6994 | //Create REQUEST | 7012 | //Create REQUEST |
6995 | // POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout | 7013 | // POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout |
6996 | - NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | 7014 | +// NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; |
7015 | + | ||
7016 | + NSMutableString *urlString = [NSMutableString string]; | ||
7017 | + | ||
7018 | + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||
7019 | + BOOL isJWTEnabled = [defaults boolForKey:WL_IS_JWT_ENABLED]; | ||
7020 | + if (isJWTEnabled) { | ||
7021 | +// /user/v5/{appUuid}/logout | ||
7022 | + urlString = [NSMutableString stringWithFormat:@"%@/user/v5/%@/logout", _baseURL, _appUUID]; | ||
7023 | + } else { | ||
7024 | + urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | ||
7025 | + } | ||
6997 | 7026 | ||
6998 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | 7027 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); |
6999 | 7028 | ||
... | @@ -8263,6 +8292,18 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg | ... | @@ -8263,6 +8292,18 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg |
8263 | NSLog(@"Beacon scanning is disabled"); | 8292 | NSLog(@"Beacon scanning is disabled"); |
8264 | } | 8293 | } |
8265 | 8294 | ||
8295 | + if ([applicationVariables objectForKey:WL_AUTHENTICATION]) { | ||
8296 | + NSString *authValue = [applicationVariables objectForKey:WL_AUTHENTICATION]; | ||
8297 | + if (authValue && [authValue isEqualToString:@"JWT"]) { | ||
8298 | + // AUTHENTICATION key exists and its value is "JWT" | ||
8299 | + [defaults setBool:YES forKey:WL_IS_JWT_ENABLED]; | ||
8300 | + } else { | ||
8301 | + [defaults setBool:NO forKey:WL_IS_JWT_ENABLED]; | ||
8302 | + } | ||
8303 | + } else { | ||
8304 | + [defaults setBool:NO forKey:WL_IS_JWT_ENABLED]; | ||
8305 | + } | ||
8306 | + | ||
8266 | [defaults setObject:[NSDate date] forKey:@"lastFeaturesUpdateTimestamp"]; | 8307 | [defaults setObject:[NSDate date] forKey:@"lastFeaturesUpdateTimestamp"]; |
8267 | 8308 | ||
8268 | //Check for device status | 8309 | //Check for device status | ... | ... |
-
Please register or login to post a comment