A server/src/systems/event/mod.rs => server/src/systems/event/mod.rs +26 -0
@@ 0,0 1,26 @@
+/*
+ * This file is part of laurelin/server
+ * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
+ *
+ * Licensed under GPL-3.0-only.
+ * See LICENSE for licensing information.
+ */
+
+use bevy_ecs::event::EventReader;
+use laurelin_shared::server::messages::Auth;
+use naia_bevy_server::{events::AuthEvents, Server};
+
+pub(crate) fn auth_events(mut ev: EventReader<AuthEvents>, mut server: Server) {
+ for events in ev.iter() {
+ for (user_key, auth) in events.read::<Auth>() {
+ match auth.username {
+ Some(username) => {
+ // register
+ }
+ None => {
+ // login
+ }
+ }
+ }
+ }
+}
M server/src/systems/mod.rs => server/src/systems/mod.rs +2 -0
@@ 7,3 7,5 @@
*/
pub(crate) mod init;
+
+pub(crate) mod event;
M shared/src/server/messages/auth.rs => shared/src/server/messages/auth.rs +4 -1
@@ 10,13 10,16 @@ use naia_bevy_shared::Message;
#[derive(Message)]
pub struct Auth {
+ /// set when registering
+ pub username: Option<String>,
pub email: String,
pub password: String,
}
impl Auth {
- pub fn new(email: &str, password: &str) -> Self {
+ pub fn new(username: Option<String>, email: &str, password: &str) -> Self {
Self {
+ username,
email: email.to_string(),
password: password.to_string(),
}