this repo has no description
0
fork

Configure Feed

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

upgrade in use check

+48 -7
+4 -1
client/src/lumina_client.gleam
··· 817 817 use greeting <- decode.field("greeting", decode.string) 818 818 decode.success(Greeting(greeting:)) 819 819 } 820 - _ -> decode.failure(Undecodable, "Unknown message type") 820 + g -> { 821 + console.error("Unknown message type: " <> g) 822 + decode.failure(Undecodable, g) 823 + } 821 824 } 822 825 } 823 826
+44 -6
server/src/user.rs
··· 206 206 password: String, 207 207 db: &DbConn, 208 208 ) -> Result<(), LuminaError> { 209 + { 210 + // Check if the email or username is already in use 211 + match db { 212 + DbConn::PgsqlConnection(client) => { 213 + // Some username and email validation should be done here 214 + // Check if the email is already in use 215 + let email_exists = client 216 + .query("SELECT * FROM users WHERE email = $1", &[&email]) 217 + .await 218 + .map_err(LuminaError::Postgres)?; 219 + if !email_exists.is_empty() { 220 + return Err(LuminaError::RegisterEmailInUse); 221 + } 222 + // Check if the username is already in use 223 + let username_exists = client 224 + .query("SELECT * FROM users WHERE username = $1", &[&username]) 225 + .await 226 + .map_err(LuminaError::Postgres)?; 227 + if !username_exists.is_empty() { 228 + return Err(LuminaError::RegisterUsernameInUse); 229 + } 230 + } 231 + DbConn::SqliteConnectionPool(pool) => { 232 + let conn = pool.get().map_err(LuminaError::SqlitePool)?; 233 + let username_exists = conn 234 + .prepare("SELECT * FROM users WHERE username = ?1") 235 + .map_err(LuminaError::Sqlite)? 236 + .exists(&[&username]) 237 + .map_err(LuminaError::Sqlite)?; 238 + if username_exists { 239 + return Err(LuminaError::RegisterUsernameInUse); 240 + } 241 + let email_exists = conn 242 + .prepare("SELECT * FROM users WHERE email = ?1") 243 + .map_err(LuminaError::Sqlite)? 244 + .exists(&[&email]) 245 + .map_err(LuminaError::Sqlite)?; 246 + if email_exists { 247 + return Err(LuminaError::RegisterEmailInUse); 248 + } 249 + } 250 + } 251 + } 252 + 209 253 // 210 254 // 211 255 // Email checks ··· 272 316 "Username too short".to_string(), 273 317 )); 274 318 } 275 - 276 - // Check if the username is already in use 277 - if let Ok(_) = User::get_user_by_identifier(username.clone(), db).await { 278 - return Err(LuminaError::RegisterUsernameInUse); 279 - }; 280 319 } 281 320 282 321 // ··· 310 349 )); 311 350 } 312 351 } 313 - 314 352 Ok(()) 315 353 }