Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Login for group and event creation page #120

Merged
merged 7 commits into from
Apr 7, 2024

Conversation

eiffelwong1
Copy link
Contributor

Summary (1-2 sentences)

require login for pages that would need access control in the future

Details (reason and description of the changes)

requires login in New group page and New event page

Copy link

vercel bot commented Mar 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plan-it-social-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 7, 2024 4:30pm

Copy link
Contributor

@andrelandgraf andrelandgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, rest looks great! Thanks!

export async function requireUserSession(request: Request) {
const session = await getUserSession(request);
if (!session) {
return redirect('/login');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return redirect('/login');
throw redirect('/login');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@tonydangblog tonydangblog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty useful. Not having to check that session exists every time saves a lot of typing :)

Copy link
Contributor

@tonydangblog tonydangblog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andrelandgraf andrelandgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -7,6 +7,11 @@ import { Card } from '~/components/ui/containers';
import { Input, TextArea } from '~/components/ui/forms';
import { Button } from '~/components/ui/button';
import { H1 } from '~/components/ui/headers';
import { requireUserSession } from '~/modules/session/session.server';

export async function loader({ request }: LoaderFunctionArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a next step, we could also check here that the user has "admin" access to the group before we allow them to create a new event for that group!

@eiffelwong1 eiffelwong1 merged commit 0b4e3d1 into main Apr 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants