Commit ce80b492 authored by Daniel Roth's avatar Daniel Roth
Browse files

Update 00-get-started

parent e4f73777
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Twitter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace BlazingPizza.Server
{
[ApiController]
public class UserController : Controller
{
private static UserInfo LoggedOutUser = new UserInfo { IsAuthenticated = false };
[HttpGet("user")]
public UserInfo GetUser()
{
return User.Identity.IsAuthenticated
? new UserInfo { Name = User.Identity.Name, IsAuthenticated = true }
: LoggedOutUser;
}
[HttpGet("user/signin")]
public async Task SignIn(string redirectUri)
{
if (string.IsNullOrEmpty(redirectUri) || !Url.IsLocalUrl(redirectUri))
{
redirectUri = "/";
}
await HttpContext.ChallengeAsync(
TwitterDefaults.AuthenticationScheme,
new AuthenticationProperties { RedirectUri = redirectUri });
}
[HttpGet("user/signout")]
public async Task<IActionResult> SignOut()
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Redirect("~/");
}
}
}
......@@ -4,7 +4,7 @@
</Found>
<NotFound>
<LayoutView Layout="typeof(MainLayout)">
<div class="main">Page not found</div>
<div class="main">Sorry, there's nothing at this address.</div>
</LayoutView>
</NotFound>
</Router>
......@@ -9,8 +9,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(BlazorVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="$(BlazorVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="$(BlazorVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(AspNetCoreVersion)" />
<PackageReference Include="System.Net.Http.Json" Version="$(SystemNetHttpJsonVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(BlazorVersion)" />
</ItemGroup>
<ItemGroup>
......
@using System.Net.Http
@using System.Net.Http.Headers
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Microsoft.JSInterop
@using BlazingPizza.Client
@using BlazingPizza.Client.Shared
......
......@@ -36,10 +36,14 @@ form {
}
.logo {
margin-right: 3rem;
width: 9rem;
display: flex;
}
.logo > img {
margin-right: 3rem;
width: 9rem;
}
.content {
display: flex;
height: 100%;
......@@ -120,6 +124,8 @@ form {
font-weight: 700;
line-height: 0.7rem;
margin-top: 0.5rem;
color: white;
font-size: 1rem;
}
.user-info a {
......@@ -127,6 +133,12 @@ form {
font-size: 0.8rem;
}
.user-info button.sign-out {
color: #fff2cc;
font-size: 0.8rem;
padding: 0;
}
.pizza-cards {
display: grid;
grid-template-columns: repeat(auto-fill, 20rem);
......@@ -540,6 +552,7 @@ a.sign-in {
font-weight: 100;
cursor: pointer;
transition: 0.2s ease-out;
margin-left: 3px;
}
a.sign-in:hover {
......@@ -548,16 +561,6 @@ a.sign-in {
border-color: #fff2cc;
}
.user-info a.sign-out {
color: #fff2cc;
font-size: 0.8rem;
cursor: pointer;
}
.user-info a.sign-out:hover {
text-decoration: underline;
}
input[type=range] {
-webkit-appearance: none;
margin: 7.1px 0;
......@@ -721,6 +724,25 @@ input[type=range] {
color: red;
}
#blazor-error-ui {
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
@keyframes progressbar-slide {
0% {
transform: translateX(-200px);
......@@ -733,4 +755,4 @@ input[type=range] {
100% {
transform: translateX(500px);
}
}
}
\ No newline at end of file
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