this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fmt!!

+229 -232
+1 -1
.editorconfig
··· 8 8 indent_size = 4 9 9 end_of_line = lf 10 10 charset = utf-8 11 - trim_trailing_whitespace = false 11 + trim_trailing_whitespace = true 12 12 insert_final_newline = true
+98 -98
client/bun.lock
··· 15 15 "", 16 16 { 17 17 "dependencies": { 18 - "@jridgewell/gen-mapping": "^0.3.5", 19 - "@jridgewell/trace-mapping": "^0.3.24" 18 + "@jridgewell/gen-mapping": "^0.3.5", 19 + "@jridgewell/trace-mapping": "^0.3.24" 20 20 } 21 21 }, 22 22 "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==" ··· 26 26 "", 27 27 { 28 28 "dependencies": { 29 - "minipass": "^7.0.4" 29 + "minipass": "^7.0.4" 30 30 } 31 31 }, 32 32 "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==" ··· 36 36 "", 37 37 { 38 38 "dependencies": { 39 - "@jridgewell/set-array": "^1.2.1", 40 - "@jridgewell/sourcemap-codec": "^1.4.10", 41 - "@jridgewell/trace-mapping": "^0.3.24" 39 + "@jridgewell/set-array": "^1.2.1", 40 + "@jridgewell/sourcemap-codec": "^1.4.10", 41 + "@jridgewell/trace-mapping": "^0.3.24" 42 42 } 43 43 }, 44 44 "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==" ··· 66 66 "", 67 67 { 68 68 "dependencies": { 69 - "@jridgewell/resolve-uri": "^3.1.0", 70 - "@jridgewell/sourcemap-codec": "^1.4.14" 69 + "@jridgewell/resolve-uri": "^3.1.0", 70 + "@jridgewell/sourcemap-codec": "^1.4.14" 71 71 } 72 72 }, 73 73 "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==" ··· 77 77 "", 78 78 { 79 79 "dependencies": { 80 - "detect-libc": "^1.0.3", 81 - "is-glob": "^4.0.3", 82 - "micromatch": "^4.0.5", 83 - "node-addon-api": "^7.0.0" 80 + "detect-libc": "^1.0.3", 81 + "is-glob": "^4.0.3", 82 + "micromatch": "^4.0.5", 83 + "node-addon-api": "^7.0.0" 84 84 }, 85 85 "optionalDependencies": { 86 - "@parcel/watcher-android-arm64": "2.5.1", 87 - "@parcel/watcher-darwin-arm64": "2.5.1", 88 - "@parcel/watcher-darwin-x64": "2.5.1", 89 - "@parcel/watcher-freebsd-x64": "2.5.1", 90 - "@parcel/watcher-linux-arm-glibc": "2.5.1", 91 - "@parcel/watcher-linux-arm-musl": "2.5.1", 92 - "@parcel/watcher-linux-arm64-glibc": "2.5.1", 93 - "@parcel/watcher-linux-arm64-musl": "2.5.1", 94 - "@parcel/watcher-linux-x64-glibc": "2.5.1", 95 - "@parcel/watcher-linux-x64-musl": "2.5.1", 96 - "@parcel/watcher-win32-arm64": "2.5.1", 97 - "@parcel/watcher-win32-ia32": "2.5.1", 98 - "@parcel/watcher-win32-x64": "2.5.1" 86 + "@parcel/watcher-android-arm64": "2.5.1", 87 + "@parcel/watcher-darwin-arm64": "2.5.1", 88 + "@parcel/watcher-darwin-x64": "2.5.1", 89 + "@parcel/watcher-freebsd-x64": "2.5.1", 90 + "@parcel/watcher-linux-arm-glibc": "2.5.1", 91 + "@parcel/watcher-linux-arm-musl": "2.5.1", 92 + "@parcel/watcher-linux-arm64-glibc": "2.5.1", 93 + "@parcel/watcher-linux-arm64-musl": "2.5.1", 94 + "@parcel/watcher-linux-x64-glibc": "2.5.1", 95 + "@parcel/watcher-linux-x64-musl": "2.5.1", 96 + "@parcel/watcher-win32-arm64": "2.5.1", 97 + "@parcel/watcher-win32-ia32": "2.5.1", 98 + "@parcel/watcher-win32-x64": "2.5.1" 99 99 } 100 100 }, 101 101 "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==" ··· 222 222 "", 223 223 { 224 224 "dependencies": { 225 - "@parcel/watcher": "^2.5.1", 226 - "@tailwindcss/node": "4.1.8", 227 - "@tailwindcss/oxide": "4.1.8", 228 - "enhanced-resolve": "^5.18.1", 229 - "mri": "^1.2.0", 230 - "picocolors": "^1.1.1", 231 - "tailwindcss": "4.1.8" 225 + "@parcel/watcher": "^2.5.1", 226 + "@tailwindcss/node": "4.1.8", 227 + "@tailwindcss/oxide": "4.1.8", 228 + "enhanced-resolve": "^5.18.1", 229 + "mri": "^1.2.0", 230 + "picocolors": "^1.1.1", 231 + "tailwindcss": "4.1.8" 232 232 }, 233 233 "bin": { 234 - "tailwindcss": "dist/index.mjs" 234 + "tailwindcss": "dist/index.mjs" 235 235 } 236 236 }, 237 237 "sha512-+6lkjXSr/68zWiabK3mVYVHmOq/SAHjJ13mR8spyB4LgUWZbWzU9kCSErlAUo+gK5aVfgqe8kY6Ltz9+nz5XYA==" ··· 241 241 "", 242 242 { 243 243 "dependencies": { 244 - "@ampproject/remapping": "^2.3.0", 245 - "enhanced-resolve": "^5.18.1", 246 - "jiti": "^2.4.2", 247 - "lightningcss": "1.30.1", 248 - "magic-string": "^0.30.17", 249 - "source-map-js": "^1.2.1", 250 - "tailwindcss": "4.1.8" 244 + "@ampproject/remapping": "^2.3.0", 245 + "enhanced-resolve": "^5.18.1", 246 + "jiti": "^2.4.2", 247 + "lightningcss": "1.30.1", 248 + "magic-string": "^0.30.17", 249 + "source-map-js": "^1.2.1", 250 + "tailwindcss": "4.1.8" 251 251 } 252 252 }, 253 253 "sha512-OWwBsbC9BFAJelmnNcrKuf+bka2ZxCE2A4Ft53Tkg4uoiE67r/PMEYwCsourC26E+kmxfwE0hVzMdxqeW+xu7Q==" ··· 257 257 "", 258 258 { 259 259 "dependencies": { 260 - "detect-libc": "^2.0.4", 261 - "tar": "^7.4.3" 260 + "detect-libc": "^2.0.4", 261 + "tar": "^7.4.3" 262 262 }, 263 263 "optionalDependencies": { 264 - "@tailwindcss/oxide-android-arm64": "4.1.8", 265 - "@tailwindcss/oxide-darwin-arm64": "4.1.8", 266 - "@tailwindcss/oxide-darwin-x64": "4.1.8", 267 - "@tailwindcss/oxide-freebsd-x64": "4.1.8", 268 - "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.8", 269 - "@tailwindcss/oxide-linux-arm64-gnu": "4.1.8", 270 - "@tailwindcss/oxide-linux-arm64-musl": "4.1.8", 271 - "@tailwindcss/oxide-linux-x64-gnu": "4.1.8", 272 - "@tailwindcss/oxide-linux-x64-musl": "4.1.8", 273 - "@tailwindcss/oxide-wasm32-wasi": "4.1.8", 274 - "@tailwindcss/oxide-win32-arm64-msvc": "4.1.8", 275 - "@tailwindcss/oxide-win32-x64-msvc": "4.1.8" 264 + "@tailwindcss/oxide-android-arm64": "4.1.8", 265 + "@tailwindcss/oxide-darwin-arm64": "4.1.8", 266 + "@tailwindcss/oxide-darwin-x64": "4.1.8", 267 + "@tailwindcss/oxide-freebsd-x64": "4.1.8", 268 + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.8", 269 + "@tailwindcss/oxide-linux-arm64-gnu": "4.1.8", 270 + "@tailwindcss/oxide-linux-arm64-musl": "4.1.8", 271 + "@tailwindcss/oxide-linux-x64-gnu": "4.1.8", 272 + "@tailwindcss/oxide-linux-x64-musl": "4.1.8", 273 + "@tailwindcss/oxide-wasm32-wasi": "4.1.8", 274 + "@tailwindcss/oxide-win32-arm64-msvc": "4.1.8", 275 + "@tailwindcss/oxide-win32-x64-msvc": "4.1.8" 276 276 } 277 277 }, 278 278 "sha512-d7qvv9PsM5N3VNKhwVUhpK6r4h9wtLkJ6lz9ZY9aeZgrUWk1Z8VPyqyDT9MZlem7GTGseRQHkeB1j3tC7W1P+A==" ··· 363 363 "", 364 364 { 365 365 "dependencies": { 366 - "@emnapi/core": "^1.4.3", 367 - "@emnapi/runtime": "^1.4.3", 368 - "@emnapi/wasi-threads": "^1.0.2", 369 - "@napi-rs/wasm-runtime": "^0.2.10", 370 - "@tybys/wasm-util": "^0.9.0", 371 - "tslib": "^2.8.0" 366 + "@emnapi/core": "^1.4.3", 367 + "@emnapi/runtime": "^1.4.3", 368 + "@emnapi/wasi-threads": "^1.0.2", 369 + "@napi-rs/wasm-runtime": "^0.2.10", 370 + "@tybys/wasm-util": "^0.9.0", 371 + "tslib": "^2.8.0" 372 372 }, 373 373 "cpu": "none" 374 374 }, ··· 397 397 "", 398 398 { 399 399 "dependencies": { 400 - "fill-range": "^7.1.1" 400 + "fill-range": "^7.1.1" 401 401 } 402 402 }, 403 403 "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==" ··· 419 419 "", 420 420 { 421 421 "bin": { 422 - "detect-libc": "./bin/detect-libc.js" 422 + "detect-libc": "./bin/detect-libc.js" 423 423 } 424 424 }, 425 425 "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==" ··· 429 429 "", 430 430 { 431 431 "dependencies": { 432 - "graceful-fs": "^4.2.4", 433 - "tapable": "^2.2.0" 432 + "graceful-fs": "^4.2.4", 433 + "tapable": "^2.2.0" 434 434 } 435 435 }, 436 436 "sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==" ··· 440 440 "", 441 441 { 442 442 "dependencies": { 443 - "to-regex-range": "^5.0.1" 443 + "to-regex-range": "^5.0.1" 444 444 } 445 445 }, 446 446 "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==" ··· 462 462 "", 463 463 { 464 464 "dependencies": { 465 - "is-extglob": "^2.1.1" 465 + "is-extglob": "^2.1.1" 466 466 } 467 467 }, 468 468 "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==" ··· 478 478 "", 479 479 { 480 480 "bin": { 481 - "jiti": "lib/jiti-cli.mjs" 481 + "jiti": "lib/jiti-cli.mjs" 482 482 } 483 483 }, 484 484 "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==" ··· 488 488 "", 489 489 { 490 490 "dependencies": { 491 - "detect-libc": "^2.0.3" 491 + "detect-libc": "^2.0.3" 492 492 }, 493 493 "optionalDependencies": { 494 - "lightningcss-darwin-arm64": "1.30.1", 495 - "lightningcss-darwin-x64": "1.30.1", 496 - "lightningcss-freebsd-x64": "1.30.1", 497 - "lightningcss-linux-arm-gnueabihf": "1.30.1", 498 - "lightningcss-linux-arm64-gnu": "1.30.1", 499 - "lightningcss-linux-arm64-musl": "1.30.1", 500 - "lightningcss-linux-x64-gnu": "1.30.1", 501 - "lightningcss-linux-x64-musl": "1.30.1", 502 - "lightningcss-win32-arm64-msvc": "1.30.1", 503 - "lightningcss-win32-x64-msvc": "1.30.1" 494 + "lightningcss-darwin-arm64": "1.30.1", 495 + "lightningcss-darwin-x64": "1.30.1", 496 + "lightningcss-freebsd-x64": "1.30.1", 497 + "lightningcss-linux-arm-gnueabihf": "1.30.1", 498 + "lightningcss-linux-arm64-gnu": "1.30.1", 499 + "lightningcss-linux-arm64-musl": "1.30.1", 500 + "lightningcss-linux-x64-gnu": "1.30.1", 501 + "lightningcss-linux-x64-musl": "1.30.1", 502 + "lightningcss-win32-arm64-msvc": "1.30.1", 503 + "lightningcss-win32-x64-msvc": "1.30.1" 504 504 } 505 505 }, 506 506 "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg==" ··· 600 600 "", 601 601 { 602 602 "dependencies": { 603 - "@jridgewell/sourcemap-codec": "^1.5.0" 603 + "@jridgewell/sourcemap-codec": "^1.5.0" 604 604 } 605 605 }, 606 606 "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==" ··· 610 610 "", 611 611 { 612 612 "dependencies": { 613 - "braces": "^3.0.3", 614 - "picomatch": "^2.3.1" 613 + "braces": "^3.0.3", 614 + "picomatch": "^2.3.1" 615 615 } 616 616 }, 617 617 "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==" ··· 627 627 "", 628 628 { 629 629 "dependencies": { 630 - "minipass": "^7.1.2" 630 + "minipass": "^7.1.2" 631 631 } 632 632 }, 633 633 "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==" ··· 637 637 "", 638 638 { 639 639 "bin": { 640 - "mkdirp": "dist/cjs/src/bin.js" 640 + "mkdirp": "dist/cjs/src/bin.js" 641 641 } 642 642 }, 643 643 "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==" ··· 689 689 "", 690 690 { 691 691 "dependencies": { 692 - "@isaacs/fs-minipass": "^4.0.0", 693 - "chownr": "^3.0.0", 694 - "minipass": "^7.1.2", 695 - "minizlib": "^3.0.1", 696 - "mkdirp": "^3.0.1", 697 - "yallist": "^5.0.0" 692 + "@isaacs/fs-minipass": "^4.0.0", 693 + "chownr": "^3.0.0", 694 + "minipass": "^7.1.2", 695 + "minizlib": "^3.0.1", 696 + "mkdirp": "^3.0.1", 697 + "yallist": "^5.0.0" 698 698 } 699 699 }, 700 700 "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==" ··· 704 704 "", 705 705 { 706 706 "dependencies": { 707 - "is-number": "^7.0.0" 707 + "is-number": "^7.0.0" 708 708 } 709 709 }, 710 710 "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==" ··· 726 726 "", 727 727 { 728 728 "dependencies": { 729 - "@emnapi/wasi-threads": "1.0.2", 730 - "tslib": "^2.4.0" 729 + "@emnapi/wasi-threads": "1.0.2", 730 + "tslib": "^2.4.0" 731 731 }, 732 732 "bundled": true 733 733 }, ··· 738 738 "", 739 739 { 740 740 "dependencies": { 741 - "tslib": "^2.4.0" 741 + "tslib": "^2.4.0" 742 742 }, 743 743 "bundled": true 744 744 }, ··· 749 749 "", 750 750 { 751 751 "dependencies": { 752 - "tslib": "^2.4.0" 752 + "tslib": "^2.4.0" 753 753 }, 754 754 "bundled": true 755 755 }, ··· 760 760 "", 761 761 { 762 762 "dependencies": { 763 - "@emnapi/core": "^1.4.3", 764 - "@emnapi/runtime": "^1.4.3", 765 - "@tybys/wasm-util": "^0.9.0" 763 + "@emnapi/core": "^1.4.3", 764 + "@emnapi/runtime": "^1.4.3", 765 + "@tybys/wasm-util": "^0.9.0" 766 766 }, 767 767 "bundled": true 768 768 }, ··· 773 773 "", 774 774 { 775 775 "dependencies": { 776 - "tslib": "^2.4.0" 776 + "tslib": "^2.4.0" 777 777 }, 778 778 "bundled": true 779 779 },
+94 -97
server/src/client_communication.rs
··· 36 36 } 37 37 possibly_json => { 38 38 match serde_json::from_str::<Message>(possibly_json) { 39 - Ok(Message::Introduction { client_kind, try_revive }) => { 40 - match client_kind.as_str() { 41 - "web" => { 42 - client_session_data.client_type = Some(ClientType::Web) 43 - } 44 - _ => {} 45 - } 46 - match try_revive { 47 - Some(token) => { 48 - let appstate = state.0.clone(); 49 - let db = &appstate.1.lock().await; 50 - match User::revive_session_from_token(token.clone(), db).await { 51 - Ok(user) => { 52 - incoming_elog!( 53 - ev_log 54 - , 55 - "Session revived for user: {}", 56 - user.clone().username.color_bright_cyan() 57 - ); 58 - client_session_data.user = Some(user.clone()); 59 - let _ = stream 60 - .send(ws::Message::from(msgtojson(Message::AuthSuccess { 61 - token: token, 62 - username: user.username, 63 - }))) 64 - .await; 65 - } 66 - Err(e) => { 67 - match e { 68 - LuminaError::Postgres(postgres_error) => { 69 - // Check if it's a "no rows returned" type error 70 - if postgres_error.to_string().contains("no rows") { 71 - info_elog!( ev_log,"Session revival failed: token not found or expired."); 72 - } else { 73 - info_elog!(ev_log,"Session revival failed: database error: {:?}", postgres_error); 74 - } 75 - } 76 - LuminaError::Sqlite(sqlite_error) => { 77 - match sqlite_error { 78 - r2d2_sqlite::rusqlite::Error::QueryReturnedNoRows => { 79 - // No rows returned - session not found or expired 80 - info_elog!(ev_log,"Session revival failed: token not found or expired."); 81 - } 82 - _ => { 83 - info_elog!(ev_log,"Session revival failed: database error: {:?}", sqlite_error); 84 - } 85 - } 86 - } 87 - _ => { 88 - info_elog!(ev_log,"Session revival failed: {:?}", e); 89 - } 90 - } 91 - let _ = stream 92 - .send(ws::Message::from(msgtojson(Message::AuthFailure))) 93 - .await; 94 - } 95 - } 96 - } 97 - None =>{ let _ = stream 39 + Ok(Message::Introduction { client_kind, try_revive }) => { 40 + match client_kind.as_str() { 41 + "web" => { 42 + client_session_data.client_type = Some(ClientType::Web) 43 + } 44 + _ => {} 45 + } 46 + match try_revive { 47 + Some(token) => { 48 + let appstate = state.0.clone(); 49 + let db = &appstate.1.lock().await; 50 + match User::revive_session_from_token(token.clone(), db).await { 51 + Ok(user) => { 52 + incoming_elog!(ev_log, "Session revived for user: {}", 53 + user.clone().username.color_bright_cyan() 54 + ); 55 + client_session_data.user = Some(user.clone()); 56 + let _ = stream 57 + .send(ws::Message::from(msgtojson(Message::AuthSuccess { 58 + token, 59 + username: user.username, 60 + }))) 61 + .await; 62 + } 63 + Err(e) => { 64 + match e { 65 + LuminaError::Postgres(postgres_error) => { 66 + // Check if it's a "no rows returned" type error 67 + if postgres_error.to_string().contains("no rows") { 68 + info_elog!( ev_log,"Session revival failed: token not found or expired."); 69 + } else { 70 + info_elog!(ev_log,"Session revival failed: database error: {:?}", postgres_error); 71 + } 72 + } 73 + LuminaError::Sqlite(sqlite_error) => { 74 + match sqlite_error { 75 + r2d2_sqlite::rusqlite::Error::QueryReturnedNoRows => { 76 + // No rows returned - session not found or expired 77 + info_elog!(ev_log,"Session revival failed: token not found or expired."); 78 + } 79 + _ => { 80 + info_elog!(ev_log,"Session revival failed: database error: {:?}", sqlite_error); 81 + } 82 + } 83 + } 84 + _ => { 85 + info_elog!(ev_log,"Session revival failed: {:?}", e); 86 + } 87 + } 88 + let _ = stream 89 + .send(ws::Message::from(msgtojson(Message::AuthFailure))) 90 + .await; 91 + } 92 + } 93 + } 94 + None =>{ let _ = stream 98 95 .send(ws::Message::from(msgtojson(Message::Greeting { 99 96 greeting: "Hello from server!".to_string(), 100 97 }))) 101 98 .await; 102 - } 103 - } 104 - }, 99 + } 100 + } 101 + }, 105 102 Ok(Message::RegisterRequest { 106 103 email, 107 104 username, ··· 130 127 Ok((session_reference, user)) => { 131 128 client_session_data.user = 132 129 Some(user.clone()); 133 - incoming_elog!(ev_log,"User {} authenticated.", 134 - user.clone().username.color_bright_cyan() 135 - ); 130 + incoming_elog!(ev_log,"User {} authenticated.", 131 + user.clone().username.color_bright_cyan() 132 + ); 136 133 let _ = stream 137 134 .send(ws::Message::from(msgtojson( 138 135 Message::AuthSuccess { ··· 146 143 match e { 147 144 LuminaError::Postgres(e) => 148 145 error_elog!(ev_log,"While creating session token: {:?}", e), 149 - LuminaError::SqlitePool(e) => 150 - warn_elog!(ev_log,"There was an error creating session token: {:?}", e), 151 - LuminaError::Sqlite(e) => 146 + LuminaError::SqlitePool(e) => 147 + warn_elog!(ev_log,"There was an error creating session token: {:?}", e), 148 + LuminaError::Sqlite(e) => 152 149 warn_elog!(ev_log,"There was an error creating session token: {:?}", e), 153 - _ => {} 150 + _ => {} 154 151 } 155 152 // I would return a more specific error message 156 153 // to the client here, but if the server knows the ··· 186 183 } 187 184 LuminaError::RegisterPasswordNotValid(why) => { 188 185 registration_error_elog!(ev_log, "Password is not valid: {}", 189 - why 190 - ); 191 - } 186 + why 187 + ); 188 + } 192 189 e => { 193 190 registration_error_elog!(ev_log, "Error creating user: {:?}", 194 - e 195 - ); 196 - } 191 + e 192 + ); 193 + } 197 194 } 198 195 199 196 // I would return a more specific error message ··· 255 252 } 256 253 Ok(Message::LoginAuthenticationRequest { email_username, password }) => 257 254 { 258 - let appstate = state.0.clone(); 255 + let appstate = state.0.clone(); 259 256 let db = &appstate.1.lock().await; 260 - let msgback = match User::authenticate(email_username.clone(), password, db).await { 257 + let msgback = match User::authenticate(email_username.clone(), password, db).await { 261 258 Ok((session_reference, user)) => { 262 - incoming_elog!(ev_log,"User {} authenticated to session with id {}.\n{}", user.username.clone().color_bright_cyan(), session_reference.session_id.to_string().color_pink(), format!("(User id: {})", user.id.to_string()).style_dim()); 263 - client_session_data.user = Some(user.clone()); 264 - Message::AuthSuccess {token: session_reference.token, username: user.username } 265 - } 266 - , 259 + incoming_elog!(ev_log,"User {} authenticated to session with id {}.\n{}", user.username.clone().color_bright_cyan(), session_reference.session_id.to_string().color_pink(), format!("(User id: {})", user.id.to_string()).style_dim()); 260 + client_session_data.user = Some(user.clone()); 261 + Message::AuthSuccess {token: session_reference.token, username: user.username } 262 + } 263 + , 267 264 Err(s) => { 268 - match s { 269 - LuminaError::AuthenticationWrongPassword => { 270 - registration_error_elog!(ev_log,"User {} {} authenticated: Incorrect credentials", email_username.color_bright_cyan(), "not".color_red()); 271 - } 272 - LuminaError::AuthenticationUserNotFound => { 273 - registration_error_elog!(ev_log,"User {} {} authenticated: User not found", email_username.color_bright_cyan(), "not".color_red()); 274 - } 275 - _ => { 276 - registration_error_elog!(ev_log,"User {} {} authenticated: {:?}", email_username.color_bright_cyan(), "not".color_red(), s); 277 - } 278 - } 279 - Message::AuthFailure 265 + match s { 266 + LuminaError::AuthenticationWrongPassword => { 267 + registration_error_elog!(ev_log,"User {} {} authenticated: Incorrect credentials", email_username.color_bright_cyan(), "not".color_red()); 268 + } 269 + LuminaError::AuthenticationUserNotFound => { 270 + registration_error_elog!(ev_log,"User {} {} authenticated: User not found", email_username.color_bright_cyan(), "not".color_red()); 271 + } 272 + _ => { 273 + registration_error_elog!(ev_log,"User {} {} authenticated: {:?}", email_username.color_bright_cyan(), "not".color_red(), s); 274 + } 275 + } 276 + Message::AuthFailure 280 277 281 - }, 282 - }; 283 - let _ = stream.send(ws::Message::from(msgtojson(msgback))).await; 278 + }, 279 + }; 280 + let _ = stream.send(ws::Message::from(msgtojson(msgback))).await; 284 281 } 285 282 Ok(Message::OwnUserInformationRequest) => { 286 283 // Handle request for user's own information
+18 -18
server/src/database.rs
··· 32 32 let conn = pool.get().map_err(LuminaError::SqlitePool)?; 33 33 let _ = conn.execute( 34 34 "CREATE TABLE IF NOT EXISTS users ( 35 - id TEXT PRIMARY KEY, 36 - email TEXT NOT NULL UNIQUE, 37 - username TEXT NOT NULL UNIQUE, 38 - password TEXT NOT NULL)", 35 + id TEXT PRIMARY KEY, 36 + email TEXT NOT NULL UNIQUE, 37 + username TEXT NOT NULL UNIQUE, 38 + password TEXT NOT NULL)", 39 39 [], 40 40 ); 41 41 let _ = conn.execute( 42 42 "CREATE TABLE IF NOT EXISTS sessions ( 43 - id TEXT PRIMARY KEY NOT NULL, 44 - user_id TEXT NOT NULL, 45 - session_key TEXT NOT NULL, 46 - created_at INT NOT NULL)", 43 + id TEXT PRIMARY KEY NOT NULL, 44 + user_id TEXT NOT NULL, 45 + session_key TEXT NOT NULL, 46 + created_at INT NOT NULL)", 47 47 [], 48 48 ); 49 49 let _ = conn.execute( ··· 150 150 .0 151 151 .execute( 152 152 "CREATE TABLE IF NOT EXISTS users ( 153 - id UUID DEFAULT gen_random_uuid (), 154 - email VARCHAR NOT NULL UNIQUE, 155 - username VARCHAR NOT NULL UNIQUE, 156 - password VARCHAR NOT NULL 157 - )", 153 + id UUID DEFAULT gen_random_uuid (), 154 + email VARCHAR NOT NULL UNIQUE, 155 + username VARCHAR NOT NULL UNIQUE, 156 + password VARCHAR NOT NULL 157 + )", 158 158 &[], 159 159 ) 160 160 .await ··· 164 164 .0 165 165 .execute( 166 166 "CREATE TABLE IF NOT EXISTS sessions ( 167 - id UUID DEFAULT gen_random_uuid (), 168 - user_id UUID NOT NULL, 169 - session_key VARCHAR NOT NULL, 170 - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP 171 - )", 167 + id UUID DEFAULT gen_random_uuid (), 168 + user_id UUID NOT NULL, 169 + session_key VARCHAR NOT NULL, 170 + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP 171 + )", 172 172 &[], 173 173 ) 174 174 .await
+18 -18
server/src/user.rs
··· 125 125 } 126 126 let id_str = Uuid::new_v4().to_string(); 127 127 let id = conn 128 - .prepare("INSERT INTO users (id, email, username, password) VALUES (?1, ?2, ?3, ?4) RETURNING id") 129 - .map_err(LuminaError::Sqlite)? 130 - .query_row(&[&id_str, &email, &username, &password], |row| { 131 - let a: String = row.get(0)?; 132 - // Unwrap: Not entirely safe. If the database is corrupted, this will panic. 133 - Ok(Uuid::from_str(a.as_str()).unwrap()) 134 - }).map_err(LuminaError::Sqlite) 135 - ?; 128 + .prepare("INSERT INTO users (id, email, username, password) VALUES (?1, ?2, ?3, ?4) RETURNING id") 129 + .map_err(LuminaError::Sqlite)? 130 + .query_row(&[&id_str, &email, &username, &password], |row| { 131 + let a: String = row.get(0)?; 132 + // Unwrap: Not entirely safe. If the database is corrupted, this will panic. 133 + Ok(Uuid::from_str(a.as_str()).unwrap()) 134 + }).map_err(LuminaError::Sqlite) 135 + ?; 136 136 Ok(User { 137 137 id, 138 138 email, ··· 247 247 match db { 248 248 DbConn::PgsqlConnection(client, _) => { 249 249 let user = client 250 - .query_one("SELECT users.id, users.email, users.username FROM users JOIN sessions ON users.id = sessions.user_id WHERE sessions.session_key = $1", &[&token]) 251 - .await 252 - .map_err(LuminaError::Postgres)?; 250 + .query_one("SELECT users.id, users.email, users.username FROM users JOIN sessions ON users.id = sessions.user_id WHERE sessions.session_key = $1", &[&token]) 251 + .await 252 + .map_err(LuminaError::Postgres)?; 253 253 Ok(User { 254 254 id: user.get(0), 255 255 email: user.get(1), ··· 259 259 DbConn::SqliteConnectionPool(pool) => { 260 260 let conn = pool.get().map_err(LuminaError::SqlitePool)?; 261 261 let user = conn.query_row("SELECT users.id, users.email, users.username FROM users JOIN sessions ON users.id = sessions.user_id WHERE sessions.session_key = ?1", &[&token], 262 - |row| { 263 - let a: String = row.get(0).unwrap(); 264 - Ok(User { 265 - id: Uuid::from_str(a.as_str()).unwrap(), 266 - email: row.get(1).unwrap(), 267 - username: row.get(2).unwrap(), 268 - }) 262 + |row| { 263 + let a: String = row.get(0).unwrap(); 264 + Ok(User { 265 + id: Uuid::from_str(a.as_str()).unwrap(), 266 + email: row.get(1).unwrap(), 267 + username: row.get(2).unwrap(), 268 + }) 269 269 }).map_err(LuminaError::Sqlite)?; 270 270 Ok(user) 271 271 }