diff --git a/src/layouts/SignInUp.astro b/src/layouts/SignInUp.astro
new file mode 100644
index 0000000..0e481ee
--- /dev/null
+++ b/src/layouts/SignInUp.astro
@@ -0,0 +1,155 @@
+---
+// Properties
+const {Title, Type} = Astro.props
+
+// Check if user is already logged in, redirect if so
+const { user } = Astro.locals;
+if (user) {
+ return Astro.redirect("/account");
+}
+---
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages/signin.astro b/src/pages/signin.astro
index d00c3ac..f17c38a 100644
--- a/src/pages/signin.astro
+++ b/src/pages/signin.astro
@@ -1,11 +1,8 @@
---
-import Layout from "../layouts/Layout.astro";
-import { SESSION_COOKIE, createAdminClient } from "../server/appwrite";
+import SignInUp from "../layouts/SignInUp.astro";
-const { user } = Astro.locals;
-if (user) {
- return Astro.redirect("/account");
-}
+import { ID } from "node-appwrite";
+import { SESSION_COOKIE, createAdminClient } from "../server/appwrite";
if (Astro.request.method === "POST") {
const data = await Astro.request.formData();
@@ -17,89 +14,15 @@ if (Astro.request.method === "POST") {
const session = await account.createEmailPasswordSession(email, password);
Astro.cookies.set(SESSION_COOKIE, session.secret, {
- path: "/",
- expires: new Date(session.expire),
- sameSite: "strict",
- secure: true,
- httpOnly: true,
+ path: "/",
+ expires: new Date(session.expire),
+ sameSite: "strict",
+ secure: true,
+ httpOnly: true,
});
return Astro.redirect("/account");
}
---
-
-
-
Demo sign in
-
-
- -
- Don't have an account? Sign up
-
-
-
-
+
\ No newline at end of file
diff --git a/src/pages/signup.astro b/src/pages/signup.astro
index 4d2fe7c..344e663 100644
--- a/src/pages/signup.astro
+++ b/src/pages/signup.astro
@@ -1,88 +1,43 @@
---
+import SignInUp from "../layouts/SignInUp.astro";
+
import { ID } from "node-appwrite";
import { SESSION_COOKIE, createAdminClient } from "../server/appwrite";
-const { user } = Astro.locals;
-if (user) {
- return Astro.redirect("/account");
-}
+
if (Astro.request.method === "POST") {
- const data = await Astro.request.formData();
+ const data = await Astro.request.formData();
- const email = data.get("email") as string;
- const password = data.get("password") as string;
- const name = data.get("name") as string;
+ const email = data.get("email") as string;
+ const password = data.get("password") as string;
+ const name = data.get("name") as string;
- const { account } = createAdminClient();
+ const { account } = createAdminClient();
- await account.create(ID.unique(), email, password, name);
- const session = await account.createEmailPasswordSession(email, password);
- const promise = account.createVerification("http://localhost:4321/verify");
+ await account.create(ID.unique(), email, password, name);
+ const session = await account.createEmailPasswordSession(email, password);
+ const promise = account.createVerification("http://localhost:4321/verify");
- promise.then(
- function (response) {
- console.log('VERI:' + response);
- },
- function (error) {
- console.log(error);
- },
- );
+ promise.then(
+ function (response) {
+ console.log('VERI:' + response);
+ },
+ function (error) {
+ console.log(error);
+ },
+ );
- Astro.cookies.set(SESSION_COOKIE, session.secret, {
- path: "/",
- expires: new Date(session.expire),
- sameSite: "strict",
- secure: true,
- httpOnly: true,
- });
+ Astro.cookies.set(SESSION_COOKIE, session.secret, {
+ path: "/",
+ expires: new Date(session.expire),
+ sameSite: "strict",
+ secure: true,
+ httpOnly: true,
+ });
- return Astro.redirect("/account");
-}
+ return Astro.redirect("/account");
+ }
---
-
-
-
-
-
-Create Anonymous Session
\ No newline at end of file
+
\ No newline at end of file