Skip to content

Commit e5a59a1

Browse files
committed
Merge branch 'feature/track-user-location-mongodb' into dev
# Conflicts: # src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs
2 parents 4be61ab + 0b51099 commit e5a59a1

16 files changed

Lines changed: 62 additions & 28 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IdentityService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public string CreateAuthorizationRequest()
1616
dic.Add("client_id", "xamarin");
1717
dic.Add("client_secret", "secret");
1818
dic.Add("response_type", "code id_token token");
19-
dic.Add("scope", "openid profile basket orders offline_access");
19+
dic.Add("scope", "openid profile basket orders locations offline_access");
2020

2121
dic.Add("redirect_uri", GlobalSetting.Instance.IdentityCallback);
2222
dic.Add("nonce", Guid.NewGuid().ToString("N"));

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/ILocationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
public interface ILocationService
77
{
8-
Task UpdateUserLocation(LocationRequest newLocReq);
8+
Task UpdateUserLocation(LocationRequest newLocReq, string token);
99
}
1010
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public LocationService(IRequestProvider requestProvider)
1414
_requestProvider = requestProvider;
1515
}
1616

17-
public async Task UpdateUserLocation(LocationRequest newLocReq)
17+
public async Task UpdateUserLocation(LocationRequest newLocReq, string token)
1818
{
1919
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.LocationEndpoint);
2020

2121
builder.Path = "api/v1/locations";
2222

2323
string uri = builder.ToString();
2424

25-
var result = await _requestProvider.PostAsync(uri, newLocReq);
25+
await _requestProvider.PostAsync(uri, newLocReq, token);
2626
}
2727
}
2828
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ private void Logout()
215215
if(Settings.UseMocks)
216216
{
217217
Settings.AuthAccessToken = string.Empty;
218-
Settings.AuthIdToken = string.Empty;
218+
Settings.AuthIdToken = string.Empty;
219219
}
220+
221+
Settings.UseFakeLocation = false;
220222
}
221223

222224
private async Task NavigateAsync(string url)

src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public double Longitude
140140
}
141141
}
142142

143+
public bool UserIsLogged => !string.IsNullOrEmpty(Settings.AuthAccessToken);
144+
143145
public ICommand ToggleMockServicesCommand => new Command(async () => await ToggleMockServicesAsync());
144146

145147
public ICommand ToggleFakeLocationCommand => new Command(() => ToggleFakeLocationAsync());
@@ -194,8 +196,9 @@ private async Task ToggleSendLocationAsync()
194196
Latitude = _latitude,
195197
Longitude = _longitude
196198
};
199+
var authToken = Settings.AuthAccessToken;
197200

198-
await _locationService.UpdateUserLocation(locationRequest);
201+
await _locationService.UpdateUserLocation(locationRequest, authToken);
199202
}
200203

201204
private void UpdateInfo()

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/SettingsView.xaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@
163163
Grid.ColumnSpan="2"/>
164164
<StackLayout
165165
Grid.Column="0"
166-
Grid.Row="4">
166+
Grid.Row="4"
167+
IsVisible="{Binding UserIsLogged}">
167168
<Label
168169
Text="{Binding TitleUseFakeLocation}"
169170
TextColor="{StaticResource GreenColor}"
@@ -179,7 +180,8 @@
179180
Animate="True"
180181
Checked="{Binding UseFakeLocation, Mode=TwoWay}"
181182
Command="{Binding ToggleFakeLocationCommand}"
182-
Style="{StaticResource SettingsToggleButtonStyle}">
183+
Style="{StaticResource SettingsToggleButtonStyle}"
184+
IsVisible="{Binding UserIsLogged}">
183185
<controls:ToggleButton.CheckedImage>
184186
<OnPlatform x:TypeArguments="ImageSource"
185187
Android="switch_on.png"
@@ -193,7 +195,7 @@
193195
WinPhone="Assets/switchOff.png"/>
194196
</controls:ToggleButton.UnCheckedImage>
195197
</controls:ToggleButton>
196-
<!-- ENDPOINT -->
198+
<!-- FAKE LOCATIONS -->
197199
<StackLayout
198200
Grid.Row="5"
199201
Grid.Column="0"
@@ -205,7 +207,7 @@
205207
Style="{StaticResource HeaderLabelStyle}"/>
206208
<Entry
207209
Text="{Binding Latitude, Mode=TwoWay}"
208-
Keyboard="Numeric">
210+
Keyboard="Text">
209211
<Entry.Style>
210212
<OnPlatform
211213
x:TypeArguments="Style"
@@ -219,7 +221,7 @@
219221
Style="{StaticResource HeaderLabelStyle}"/>
220222
<Entry
221223
Text="{Binding Longitude, Mode=TwoWay}"
222-
Keyboard="Numeric">
224+
Keyboard="Text">
223225
<Entry.Style>
224226
<OnPlatform
225227
x:TypeArguments="Style"

src/Services/Identity/Identity.API/Configuration/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
7777
"locations"
7878
},
7979
//Allow requesting refresh tokens for long lived API access
80-
AllowOfflineAccess = true
80+
AllowOfflineAccess = true,
81+
AllowAccessTokensViaBrowser = true
8182
},
8283
new Client
8384
{

src/Services/Location/Locations.API/Controllers/LocationsController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public LocationsController(ILocationsService locationsService, IIdentityService
2121
}
2222

2323
//GET api/v1/[controller]/user/1
24-
[Route("user/{userId:int}")]
24+
[Route("user/{userId:guid}")]
2525
[HttpGet]
26-
public async Task<IActionResult> GetUserLocation(int userId)
26+
public async Task<IActionResult> GetUserLocation(Guid userId)
2727
{
28-
var userLocation = await _locationsService.GetUserLocation(userId);
28+
var userLocation = await _locationsService.GetUserLocation(userId.ToString());
2929
return Ok(userLocation);
3030
}
3131

src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface ILocationsRepository
1111

1212
Task<List<Locations>> GetLocationListAsync();
1313

14-
Task<UserLocation> GetUserLocationAsync(int userId);
14+
Task<UserLocation> GetUserLocationAsync(string userId);
1515

1616
Task<List<Locations>> GetCurrentUserRegionsListAsync(LocationRequest currentPosition);
1717

src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task<Locations> GetAsync(string locationId)
2828
.FirstOrDefaultAsync();
2929
}
3030

31-
public async Task<UserLocation> GetUserLocationAsync(int userId)
31+
public async Task<UserLocation> GetUserLocationAsync(string userId)
3232
{
3333
var filter = Builders<UserLocation>.Filter.Eq("UserId", userId);
3434
return await _context.UserLocation

0 commit comments

Comments
 (0)