Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
s8_ivanov_r
VPL-pizza-shop-blazor
Commits
e5d60d4c
Commit
e5d60d4c
authored
Jan 27, 2019
by
Ryan Nowak
Browse files
Add a missing part to step 05
parent
aa463a7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
docs/05-authentication-and-authorization.md
docs/05-authentication-and-authorization.md
+2
-0
save-points/05-add-authentication/BlazingPizza.Client/Pages/Index.cshtml
...add-authentication/BlazingPizza.Client/Pages/Index.cshtml
+10
-3
save-points/06-javascript-interop/BlazingPizza.Client/Pages/Index.cshtml
...javascript-interop/BlazingPizza.Client/Pages/Index.cshtml
+10
-3
No files found.
docs/05-authentication-and-authorization.md
View file @
e5d60d4c
...
...
@@ -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
save-points/05-add-authentication/BlazingPizza.Client/Pages/Index.cshtml
View file @
e5d60d4c
...
...
@@ -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");
}
}
}
save-points/06-javascript-interop/BlazingPizza.Client/Pages/Index.cshtml
View file @
e5d60d4c
...
...
@@ -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");
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment