Skip to content

Commit 694383f

Browse files
committed
Improve Sign In Button / Register user flow
1 parent e715042 commit 694383f

7 files changed

Lines changed: 189 additions & 26 deletions

File tree

MyApp.Client/components/nav.tsx

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@ export default function () {
2323
]
2424

2525
const { user, hasRole, signOut } = appAuth()
26+
const navClass = (path:string) => [
27+
"p-4 flex items-center justify-start mw-full hover:text-sky-500 dark:hover:text-sky-400",
28+
router.asPath === path || router.asPath.startsWith(path + '/') ? "text-link-dark dark:text-link-dark" : "",
29+
].join(" ")
30+
2631
const router = useRouter()
27-
if (user) {
28-
items.push(...[
29-
hasRole('Admin')
30-
? { href:"/admin", name:"Admin", show:"role:Admin" }
31-
: { href:"/profile", name:"Profile" },
32-
{ type:'Button', onClick: () => signOut('/'), name:"Sign Out" },
33-
].filter(x => !!x))
34-
} else {
35-
items.push({ type:'Button', href:"/signin", name:"Sign In" })
36-
}
3732

3833
return (<header className="border-b border-gray-200 dark:border-gray-700 pr-3 bg-white dark:bg-gray-800">
3934
<div className="flex flex-wrap items-center">
@@ -56,6 +51,40 @@ export default function () {
5651
</Link>)}
5752
</li>)
5853
})}
54+
{user
55+
? (<>
56+
{hasRole('Admin')
57+
? <li className="relative flex flex-wrap just-fu-start m-0">
58+
<Link href="/admin" className={navClass('/admin')}>Admin</Link>
59+
</li> : null}
60+
<li>
61+
<div className="mx-3 relative">
62+
<div>
63+
<Link href="/profile"
64+
className="max-w-xs rounded-full flex items-center text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 lg:p-2 lg:rounded-md lg:hover:bg-gray-50 dark:lg:hover:bg-gray-900 dark:ring-offset-black"
65+
id="user-menu-button" aria-expanded="false" aria-haspopup="true">
66+
<img className="h-8 w-8 rounded-full" src={user.profileUrl} alt=""/>
67+
<span
68+
className="hidden ml-3 text-gray-700 dark:text-gray-300 text-sm font-medium lg:block">
69+
<span className="sr-only">Open user menu for </span>
70+
{user.userName}
71+
</span>
72+
</Link>
73+
</div>
74+
</div>
75+
</li>
76+
<li className="mr-3 relative flex flex-wrap just-fu-start m-0">
77+
<SecondaryButton onClick={() => signOut()}>
78+
Sign Out
79+
</SecondaryButton>
80+
</li>
81+
</>)
82+
: (<li className="relative flex flex-wrap just-fu-start m-0">
83+
<SecondaryButton className="m-2">
84+
<Link href="/signin">Sign In</Link>
85+
</SecondaryButton>
86+
</li>)
87+
}
5988
<li className="relative flex flex-wrap just-fu-start m-0">
6089
<DarkModeToggle />
6190
</li>

MyApp.Client/log.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Loading
Lines changed: 51 additions & 0 deletions
Loading
Lines changed: 41 additions & 0 deletions
Loading

MyApp/Configure.AppHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void Configure(IWebHostBuilder builder) => builder
1212
// Configure ASP.NET Core IOC Dependencies
1313
services.AddSingleton(new AppConfig {
1414
AppBaseUrl = context.HostingEnvironment.IsDevelopment()
15-
? "http://localhost" +
15+
? "https://localhost" +
1616
":3000" +
1717
""
1818
: null,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For more, see development workflow docs for **JetBrains Rider** and **VS Code /
3333

3434
#### Use npm dev server for UI Development
3535

36-
- http://localhost:3000
36+
- https://localhost:3000
3737

3838
#### `npm run build:local` to view in .NET App
3939

@@ -74,7 +74,7 @@ npx create-next-app --example blog-starter-typescript blog-starter-typescript-ap
7474
yarn create next-app --example blog-starter-typescript blog-starter-typescript-app
7575
```
7676

77-
Your blog should be up and running on [http://localhost:3000](http://localhost:3000)! If it doesn't work, post on [GitHub discussions](https://github.com/vercel/next.js/discussions).
77+
Your blog should be up and running on [https://localhost:3000](https://localhost:3000)! If it doesn't work, post on [GitHub discussions](https://github.com/vercel/next.js/discussions).
7878

7979
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
8080

0 commit comments

Comments
 (0)