Skip to content

Commit 5afb389

Browse files
Directly return error about missing username field
1 parent 03e7133 commit 5afb389

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.changeset/dark-horses-feel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fujocoded/authproto": patch
3+
---
4+
5+
Directly return error about missing username field

astro-authproto/src/routes/oauth/login.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ export const POST: APIRoute = async ({ redirect, request, session }) => {
2323
...(referer && !customRedirect && { referer }),
2424
};
2525

26+
if (!atprotoId) {
27+
session?.set(AUTHPROTO_ERROR_CODE, "MISSING_FIELD");
28+
session?.set(
29+
AUTHPROTO_ERROR_DESCRIPTION,
30+
'Missing required "atproto-id" field in login form data',
31+
);
32+
return redirect(stateData.referer || "/");
33+
}
34+
2635
try {
27-
const url = await oauthClient.authorize(atprotoId!, {
36+
const url = await oauthClient.authorize(atprotoId, {
2837
scope: scopes.join(" "),
2938
// This random value protects against CSRF (Cross-Site Request
3039
// Forgery) attacks. We send it along our authorization request, and the OAuth

0 commit comments

Comments
 (0)