login and register are sending data to the backend successfuly

This commit is contained in:
filipriec
2025-08-29 14:46:43 +02:00
parent 833b918c5b
commit 75da9c0f4b
4 changed files with 18 additions and 2 deletions

View File

@@ -132,11 +132,12 @@ pub async fn back_to_main(
/// Validates input, shows loading, and spawns the login task. /// Validates input, shows loading, and spawns the login task.
pub fn initiate_login( pub fn initiate_login(
login_state: &LoginFormState, login_state: &mut LoginFormState,
app_state: &mut AppState, app_state: &mut AppState,
mut auth_client: AuthClient, mut auth_client: AuthClient,
sender: mpsc::Sender<LoginResult>, sender: mpsc::Sender<LoginResult>,
) -> String { ) -> String {
login_state.sync_from_editor();
let username = login_state.username().to_string(); let username = login_state.username().to_string();
let password = login_state.password().to_string(); let password = login_state.password().to_string();

View File

@@ -139,6 +139,13 @@ impl fmt::Debug for LoginFormState {
} }
impl LoginFormState { impl LoginFormState {
/// Sync the editor's data provider back into our state
pub fn sync_from_editor(&mut self) {
// FormEditor holds the authoritative data
let dp = self.editor.data_provider();
self.state = dp.clone(); // LoginState implements Clone
}
/// Create a new LoginFormState with default LoginState and FormEditor /// Create a new LoginFormState with default LoginState and FormEditor
pub fn new() -> Self { pub fn new() -> Self {
let state = LoginState::default(); let state = LoginState::default();

View File

@@ -62,11 +62,12 @@ pub async fn back_to_login(
/// Validates input, shows loading, and spawns the registration task. /// Validates input, shows loading, and spawns the registration task.
pub fn initiate_registration( pub fn initiate_registration(
register_state: &RegisterFormState, register_state: &mut RegisterFormState,
app_state: &mut AppState, app_state: &mut AppState,
mut auth_client: AuthClient, mut auth_client: AuthClient,
sender: mpsc::Sender<RegisterResult>, sender: mpsc::Sender<RegisterResult>,
) -> String { ) -> String {
register_state.sync_from_editor();
let username = register_state.username().to_string(); let username = register_state.username().to_string();
let email = register_state.email().to_string(); let email = register_state.email().to_string();
let password = register_state.password().to_string(); let password = register_state.password().to_string();

View File

@@ -206,6 +206,13 @@ impl fmt::Debug for RegisterFormState {
} }
impl RegisterFormState { impl RegisterFormState {
/// Sync the editor's data provider back into our state
pub fn sync_from_editor(&mut self) {
// The FormEditor holds the authoritative data
let dp = self.editor.data_provider();
self.state = dp.clone(); // because RegisterState: Clone
}
pub fn new() -> Self { pub fn new() -> Self {
let state = RegisterState::default(); let state = RegisterState::default();
let editor = FormEditor::new(state.clone()); let editor = FormEditor::new(state.clone());