Skip to content

Commit a5ba51d

Browse files
committed
feat: enhance type safety in OAuth parameters and organization selection; improve error handling for organization name submission
1 parent 599d66a commit a5ba51d

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/routes/(no-layout)/login/+page.server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { auth } from '$lib/stores/auth';
99
import { v4 as uuidv4 } from 'uuid';
1010

1111

12+
/**
13+
* @param {Object} params - OAuth parameters
14+
* @param {string} params.access_token - Access token
15+
*/
1216
async function fetchUserData(params) {
1317
const url = 'https://www.googleapis.com/oauth2/v1/userinfo'
1418

src/routes/(no-layout)/login/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<div class="flex items-center p-3 bg-white/10 backdrop-blur-sm rounded-xl border border-white/20"
107107
in:fly="{{ y: 30, duration: 600, delay: 600 + (i * 100) }}">
108108
<div class="rounded-lg bg-white/20 p-2 mr-3">
109-
{#snippet featureIcon(icon)}
109+
{#snippet featureIcon(/** @type {any} */ icon)}
110110
{@const FeatureIcon = icon}
111111
<FeatureIcon class="w-5 h-5" />
112112
{/snippet}

src/routes/(no-layout)/org/+page.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
const { orgs } = data;
1010
1111
// Function to handle organization selection
12+
/**
13+
* @param {Object} org - Organization object
14+
* @param {string} org.id - Organization ID
15+
* @param {string} org.name - Organization name
16+
*/
1217
function selectOrg(org) {
1318
if (browser) {
1419
// Set both org id and org name in cookies

src/routes/(no-layout)/org/new/+page.server.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ export const actions = {
2323

2424
// Get the submitted form data
2525
const formData = await request.formData();
26-
const orgName = formData.get('org_name');
26+
const orgName = formData.get('org_name')?.toString();
27+
28+
if (!orgName) {
29+
return {
30+
error: {
31+
name: 'Organization name is required'
32+
}
33+
};
34+
}
2735

2836
try {
2937
// Check if organization with the same name already exists

0 commit comments

Comments
 (0)