Commit e5d60d4c authored by Ryan Nowak's avatar Ryan Nowak
Browse files

Add a missing part to step 05

parent aa463a7e
......@@ -8,5 +8,7 @@ Rough Notes:
- Decorating the router with UserStateProvider makes UserState available everywhere
- Write the UserInfo component - the only new feature here is consuming a cascading parameter
- Add the UserInfo component to the layout so you can see sign-in/sign-out from every page
- Use the UserStateProvider cascading parameter from Index
- Add a call to UserStateProvider.TrySignIn on Index when an order is submitted. We don't want to allow unauthenticated orders now
- Adding a new layout ForceSigninLayout that prevents rendering of content when not signed in
- Apply this layout to the MyOrders page and OrderDetails page will trigger a signin on navigation
\ No newline at end of file
......@@ -54,6 +54,8 @@
}
@functions {
[CascadingParameter] UserStateProvider UserState { get; set; }
List<PizzaSpecial> specials;
protected async override Task OnInitAsync()
......@@ -71,8 +73,13 @@
async Task PlaceOrder()
{
await HttpClient.PostJsonAsync("/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
// The server will reject the submission if you're not signed in, so attempt
// to sign in first if needed
if (await UserState.TrySignInAsync())
{
await HttpClient.PostJsonAsync("/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
}
}
}
......@@ -54,6 +54,8 @@
}
@functions {
[CascadingParameter] UserStateProvider UserState { get; set; }
List<PizzaSpecial> specials;
protected async override Task OnInitAsync()
......@@ -71,8 +73,13 @@
async Task PlaceOrder()
{
await HttpClient.PostJsonAsync("/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
// The server will reject the submission if you're not signed in, so attempt
// to sign in first if needed
if (await UserState.TrySignInAsync())
{
await HttpClient.PostJsonAsync("/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment