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

feature: login #32

Merged
merged 40 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f59aeb4
feat: add login page
limwa Jan 5, 2025
864ed4a
style: add lint for frontend
limwa Jan 5, 2025
4537c4e
feat: initialize social authentication
limwa Jan 5, 2025
0112aed
feat: add login form and oauth verification
limwa Jan 6, 2025
55c1c9e
refactor: public url for tuyau
limwa Jan 8, 2025
9874e14
feat: add account model
limwa Jan 8, 2025
f9ddcb2
feat: login and showing invalid credential error
tomaspalma Jan 8, 2025
c0d0f51
chore: remove unsued import
tomaspalma Jan 8, 2025
91e26b0
feat: login and registering working with account and model architecture
tomaspalma Jan 16, 2025
afcdb8e
feat: middleware to redirect from login and register if user is logge…
tomaspalma Jan 17, 2025
917705f
feat: error reporting for register if email is taken or password != c…
tomaspalma Jan 17, 2025
ebf0f8a
feat: added login button to navbar and changed login and register bac…
tomaspalma Jan 17, 2025
3db2d68
feat: email and password length validation on backend
tomaspalma Jan 19, 2025
4fd21c0
Merge branch 'main' into feature/login
tomaspalma Jan 19, 2025
e10b94a
fix: confirm password does not give false positives anymore
tomaspalma Jan 19, 2025
b6e14ee
Merge branch 'main' into feature/login
limwa Jan 19, 2025
f8a99b7
fix: shadowed variable on ssr.tsx
tomaspalma Jan 20, 2025
293c3f8
feat: implement react email and part of email verification
limwa Jan 21, 2025
80bcdc8
feat: add limiter and change route names
limwa Jan 21, 2025
ed20c1b
refactor: change auth service to user service
limwa Jan 21, 2025
b456157
build: upgrade dependencies
limwa Jan 21, 2025
21f90d0
refactor: move validation messages to #start/validator
limwa Jan 21, 2025
3db18b5
chore: add migrations
limwa Jan 21, 2025
cfefe4b
feat: finish email confirmation flow, login and register
limwa Jan 22, 2025
3a17ff7
chore: make deployment script fail with invalid env variables
limwa Jan 22, 2025
291df10
chore: change entrypoint shell
limwa Jan 22, 2025
c1d5450
fix: handle caught exceptions
limwa Jan 22, 2025
e2af983
chore: allow fresh migrations on entrypoint
limwa Jan 22, 2025
3f98a65
fix: no need for inertia.always
limwa Jan 22, 2025
79ff027
feat: add cooldown to email verification page
limwa Jan 22, 2025
8be45c8
feat: make verification pages ui/ux better
limwa Jan 22, 2025
c3926e5
fix: make authentication emails use sans serif font
limwa Jan 22, 2025
3d14167
feat: small ux improvements
limwa Jan 22, 2025
e02f304
feat: use beige background in verification email
limwa Jan 22, 2025
234dd45
Update card.tsx
limwa Jan 22, 2025
6cd0f10
refactor: some changes here and there
limwa Jan 22, 2025
efce55e
chore: some more stuff
limwa Jan 23, 2025
1cf1bc9
refactor: small change
limwa Jan 23, 2025
8c6e4ef
chore: stop using verbatimModuleSyntax on frontend
limwa Jan 23, 2025
2e8352a
fix: errors while rendering status pages
limwa Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: errors while rendering status pages
limwa committed Jan 24, 2025
commit 2e8352adc55b589cebbf937af0247c459f7fdddf
2 changes: 1 addition & 1 deletion website/.env.example
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ LINKEDIN_CLIENT_ID=********
LINKEDIN_CLIENT_SECRET=********

# Feature flags
FEATURES_DISABLE_AUTH=true
FEATURES_DISABLE_AUTH=false

# Frontend
INERTIA_PUBLIC_TZ=Europe/Lisbon
11 changes: 7 additions & 4 deletions website/app/exceptions/handler.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* codes. You might want to enable them in production only, but feel
* free to enable them in development as well.
*/
protected renderStatusPages = true
protected renderStatusPages = app.inProduction

protected ignoreCodes = ["E_AUTH_DISABLED"]

@@ -23,9 +23,12 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* to return the HTML contents to send as a response.
*/
protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {
'403': (error, { inertia }) => inertia.render('errors/forbidden', { error }),
'404': (error, { inertia }) => inertia.render('errors/not_found', { error }),
'500..599': (error, { inertia }) => inertia.render('errors/server_error', { error }),
// '403': (error, { inertia }) => inertia.render('errors/forbidden', { error }),
'403': (_error, { response }) => response.status(403).finish(),
// '404': (error, { inertia }) => inertia.render('errors/not_found', { error }),
'404': (_error, { response }) => response.status(404).finish(),
// '500..599': (error, { inertia }) => inertia.render('errors/server_error', { error }),
'500..599': (_error, { response }) => response.status(500).finish(),
}

/**
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import env from '#start/env'
import type { HttpContext } from '@adonisjs/core/http'
import type { NextFn } from '@adonisjs/core/types/http'

export default class RequireAuthEnabledMiddleware {
export default class RequireAuthenticationEnabledMiddleware {
async handle(_ctx: HttpContext, next: NextFn) {
if (env.get('FEATURES_DISABLE_AUTH')) {
throw new AuthenticationDisabledException()
7 changes: 2 additions & 5 deletions website/inertia/hooks/use_auth.ts
Original file line number Diff line number Diff line change
@@ -12,13 +12,10 @@ type UseAuthResult<Props extends UseAuthProps> = Props["only"] extends (infer On
: AuthenticationData

export function useAuth<Props extends UseAuthProps>(props?: Props) {
const only = props?.only ?? []
const only = props?.only

const auth = usePage<SharedProps>().props.auth
const valid = useMemo<boolean>(() => {
if (only === undefined) return true
return only.includes(auth.state)
}, [auth, only])
const valid = useMemo(() => only?.includes(auth.state) ?? true, [auth, only])

if (!valid) throw new Error('Assertion failed: authentication state is not permitted')

2 changes: 1 addition & 1 deletion website/inertia/pages/errors/forbidden.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseLayout from '~/layouts/base'

export default function Forbidden({}: { error: any }) {
export default function Forbidden() {
return (
<BaseLayout title="You should not be here">
<div className="">