Skip to content

Commit

Permalink
fix: register action. login after registration success
Browse files Browse the repository at this point in the history
  • Loading branch information
zerj9 committed Nov 16, 2024
1 parent 64b83f5 commit f09256a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gridwalk-ui/src/app/login/components/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export async function loginAction(formData: { email: string; password: string })
// maxAge: 60 * 60 * 24 * 7, // 1 week
// domain: 'your-domain.com',
});

return data;
}

export async function registerAction(formData: {
Expand All @@ -54,10 +52,14 @@ export async function registerAction(formData: {
body: JSON.stringify(formData),
});

const data = await response.json();
if (!response.ok) {
const data = await response.json();
throw new Error(data.error || 'Registration failed');
}

return data;
// After successful registration, log the user in
return await loginAction({
email: formData.email,
password: formData.password,
});
}

0 comments on commit f09256a

Please sign in to comment.