-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
435 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Authenticator } from "remix-auth"; | ||
import { steamSessionStorage } from "./sessions.server"; | ||
import { SteamStrategy, SteamStrategyVerifyParams } from "remix-auth-steam"; | ||
|
||
export type User = SteamStrategyVerifyParams; | ||
|
||
export const authenticator = new Authenticator<User>(steamSessionStorage); | ||
|
||
authenticator.use( | ||
new SteamStrategy( | ||
{ | ||
returnURL: `${process.env.BASE_URL || 'http://localhost:5173'}/auth/steam/callback`, | ||
apiKey: process.env.STEAM_API_KEY! as string, | ||
}, async (user) => user | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { authenticator } from "~/auth.server"; | ||
|
||
export async function loader({request}: LoaderFunctionArgs) { | ||
await authenticator.logout(request, { redirectTo: '/' }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { authenticator } from "~/auth.server"; | ||
|
||
export async function loader({request}: LoaderFunctionArgs) { | ||
return authenticator.authenticate('steam', request, { | ||
successRedirect: '/dashboard', | ||
failureRedirect: '/', | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { authenticator } from "~/auth.server"; | ||
|
||
export async function loader({request}: LoaderFunctionArgs) { | ||
await authenticator.authenticate('steam', request, {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { Link, useLoaderData, useNavigate, type MetaFunction } from "@remix-run/react"; | ||
import { authenticator } from "~/auth.server"; | ||
|
||
export const meta: MetaFunction = () => { | ||
return [ | ||
{ title: 'TriumphTF2 - Dashboard' }, | ||
{ description: 'Your dashboard' }, | ||
]; | ||
}; | ||
|
||
export async function loader({request}: LoaderFunctionArgs) { | ||
const auth = await authenticator.isAuthenticated(request); | ||
if (auth == null) { | ||
await authenticator.authenticate('steam', request, { | ||
successRedirect: '/dashboard', | ||
failureRedirect: '/', | ||
}); | ||
} | ||
return {auth: auth}; | ||
} | ||
|
||
export default function Dashboard() { | ||
const data = useLoaderData<typeof loader>(); | ||
const navigate = useNavigate(); | ||
if (data.auth == null) { | ||
navigate('/'); | ||
return <></>; | ||
} | ||
return ( | ||
<div> | ||
<h1>Dashboard</h1> | ||
<p>Welcome, {data.auth.nickname}!</p> | ||
<p>This is a placeholder page. More content to come!</p> | ||
<Link to="/auth/logout">Logout</Link> - <Link to="/">Home</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.