From 0ccedc67179d770739e357bd95cdd439c9a6a409 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 15 Apr 2022 19:43:12 +0200 Subject: [PATCH] app: Fix password reset --- app/src/components/reset_password_step2.rs | 15 +++++++++------ app/src/infra/api.rs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/components/reset_password_step2.rs b/app/src/components/reset_password_step2.rs index 45b59e1..992a846 100644 --- a/app/src/components/reset_password_step2.rs +++ b/app/src/components/reset_password_step2.rs @@ -6,7 +6,10 @@ use crate::{ }, }; use anyhow::{bail, Context, Result}; -use lldap_auth::*; +use lldap_auth::{ + opaque::client::registration as opaque_registration, + password_reset::ServerPasswordResetResponse, registration, +}; use validator_derive::Validate; use yew::prelude::*; use yew_form::Form; @@ -29,7 +32,7 @@ pub struct ResetPasswordStep2Form { common: CommonComponentParts, form: Form, username: Option, - opaque_data: Option, + opaque_data: Option, route_dispatcher: RouteAgentDispatcher, } @@ -39,7 +42,7 @@ pub struct Props { } pub enum Msg { - ValidateTokenResponse(Result), + ValidateTokenResponse(Result), FormUpdate, Submit, RegistrationStartResponse(Result>), @@ -50,7 +53,7 @@ impl CommonComponent for ResetPasswordStep2Form { fn handle_msg(&mut self, msg: ::Message) -> Result { match msg { Msg::ValidateTokenResponse(response) => { - self.username = Some(response?); + self.username = Some(response?.user_id); self.common.cancel_task(); Ok(true) } @@ -62,7 +65,7 @@ impl CommonComponent for ResetPasswordStep2Form { let mut rng = rand::rngs::OsRng; let new_password = self.form.model().password; let registration_start_request = - opaque::client::registration::start_registration(&new_password, &mut rng) + opaque_registration::start_registration(&new_password, &mut rng) .context("Could not initiate password change")?; let req = registration::ClientRegistrationStartRequest { username: self.username.clone().unwrap(), @@ -80,7 +83,7 @@ impl CommonComponent for ResetPasswordStep2Form { let res = res.context("Could not initiate password change")?; let registration = self.opaque_data.take().expect("Missing registration data"); let mut rng = rand::rngs::OsRng; - let registration_finish = opaque::client::registration::finish_registration( + let registration_finish = opaque_registration::finish_registration( registration, res.registration_response, &mut rng, diff --git a/app/src/infra/api.rs b/app/src/infra/api.rs index 17871b8..89d87d4 100644 --- a/app/src/infra/api.rs +++ b/app/src/infra/api.rs @@ -251,7 +251,7 @@ impl HostService { pub fn reset_password_step2( token: &str, - callback: Callback>, + callback: Callback>, ) -> Result { call_server_json_with_error_message( &format!("/auth/reset/step2/{}", token),