diff --git a/.env b/.env
new file mode 100644
index 0000000..2fefae9
--- /dev/null
+++ b/.env
@@ -0,0 +1 @@
+APP_URL="http://localhost:8080"
\ No newline at end of file
diff --git a/assets/icon.svg b/assets/icon.svg
index ec6a62c..2e9ada8 100644
--- a/assets/icon.svg
+++ b/assets/icon.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/assets/tailwind.css b/assets/tailwind.css
index 2757d9f..90cc162 100644
--- a/assets/tailwind.css
+++ b/assets/tailwind.css
@@ -25,7 +25,6 @@
--color-emerald-600: oklch(59.6% 0.145 163.225);
--color-cyan-50: oklch(98.4% 0.019 200.873);
--color-indigo-50: oklch(96.2% 0.018 272.314);
- --color-indigo-100: oklch(93% 0.034 272.788);
--color-indigo-300: oklch(78.5% 0.115 274.713);
--color-indigo-400: oklch(67.3% 0.182 276.935);
--color-indigo-500: oklch(58.5% 0.233 277.117);
@@ -74,6 +73,8 @@
--text-xl--line-height: calc(1.75 / 1.25);
--text-2xl: 1.5rem;
--text-2xl--line-height: calc(2 / 1.5);
+ --text-3xl: 1.875rem;
+ --text-3xl--line-height: calc(2.25 / 1.875);
--text-4xl: 2.25rem;
--text-4xl--line-height: calc(2.5 / 2.25);
--text-5xl: 3rem;
@@ -391,6 +392,9 @@
.inline-flex {
display: inline-flex;
}
+ .table {
+ display: table;
+ }
.h-0\.5 {
height: calc(var(--spacing) * 0.5);
}
@@ -472,6 +476,9 @@
.w-\[1000px\] {
width: 1000px;
}
+ .w-auto {
+ width: auto;
+ }
.w-full {
width: 100%;
}
@@ -537,6 +544,9 @@
.appearance-none {
appearance: none;
}
+ .grid-cols-1 {
+ grid-template-columns: repeat(1, minmax(0, 1fr));
+ }
.flex-col {
flex-direction: column;
}
@@ -561,6 +571,9 @@
.gap-6 {
gap: calc(var(--spacing) * 6);
}
+ .gap-8 {
+ gap: calc(var(--spacing) * 8);
+ }
.space-y-1 {
:where(& > :not(:last-child)) {
--tw-space-y-reverse: 0;
@@ -748,9 +761,6 @@
.bg-green-600 {
background-color: var(--color-green-600);
}
- .bg-indigo-100 {
- background-color: var(--color-indigo-100);
- }
.bg-indigo-500\/20 {
background-color: color-mix(in srgb, oklch(58.5% 0.233 277.117) 20%, transparent);
@supports (color: color-mix(in lab, red, red)) {
@@ -1013,6 +1023,10 @@
font-size: var(--text-2xl);
line-height: var(--tw-leading, var(--text-2xl--line-height));
}
+ .text-3xl {
+ font-size: var(--text-3xl);
+ line-height: var(--tw-leading, var(--text-3xl--line-height));
+ }
.text-4xl {
font-size: var(--text-4xl);
line-height: var(--tw-leading, var(--text-4xl--line-height));
@@ -1101,9 +1115,6 @@
.text-indigo-400 {
color: var(--color-indigo-400);
}
- .text-indigo-600 {
- color: var(--color-indigo-600);
- }
.text-indigo-900\/50 {
color: color-mix(in srgb, oklch(35.9% 0.144 278.697) 50%, transparent);
@supports (color: color-mix(in lab, red, red)) {
@@ -1351,6 +1362,13 @@
}
}
}
+ .hover\:bg-red-700 {
+ &:hover {
+ @media (hover: hover) {
+ background-color: var(--color-red-700);
+ }
+ }
+ }
.hover\:bg-slate-200 {
&:hover {
@media (hover: hover) {
diff --git a/src/auth.rs b/src/auth.rs
index 937e174..4f253ce 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -21,14 +21,43 @@ use tower_sessions::Session;
pub struct UserSafe {
pub id: i32,
pub username: String,
+ pub is_server_admin: bool,
}
#[server]
-pub async fn register(username: String, password: String) -> Result {
+pub async fn register(
+ username: String,
+ password: String,
+ invite_token: Option,
+) -> Result {
let db = db::establish_connection()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
+ // Check if this is the first user
+ let user_count = User::find()
+ .count(&db)
+ .await
+ .map_err(|e| ServerFnError::new(e.to_string()))?;
+ let is_admin = user_count == 0;
+
+ // If not the first user, require a valid invite token
+ if !is_admin {
+ let token = invite_token.ok_or(ServerFnError::new("Einladungscode erforderlich"))?;
+
+ // Verify token exists in events table
+ let event_exists = db::events::Entity::find()
+ .filter(db::events::Column::InviteToken.eq(token))
+ .one(&db)
+ .await
+ .map_err(|e| ServerFnError::new(e.to_string()))?
+ .is_some();
+
+ if !event_exists {
+ return Err(ServerFnError::new("Ungültiger Einladungscode"));
+ }
+ }
+
let salt = SaltString::generate(&mut OsRng);
let argon2 = Argon2::default();
let password_hash = argon2
@@ -39,6 +68,7 @@ pub async fn register(username: String, password: String) -> Result Result Result Result