commit c698bca2b934aee83ed33668a7513d9c3db223bf
parent 978be0b4a9a904a2ffbd227821cf8f14cf4e4243
Author: Mathijs van Veluw <black.dex@gmail.com>
Date: Fri, 25 Sep 2020 22:25:57 +0200
Merge branch 'master' into mariadb-fk-issues
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs
@@ -32,6 +32,7 @@ pub fn routes() -> Vec<rocket::Route> {
revision_date,
password_hint,
prelogin,
+ verify_password,
]
}
@@ -623,3 +624,20 @@ fn prelogin(data: JsonUpcase<PreloginData>, conn: DbConn) -> JsonResult {
"KdfIterations": kdf_iter
})))
}
+#[derive(Deserialize)]
+#[allow(non_snake_case)]
+struct VerifyPasswordData {
+ MasterPasswordHash: String,
+}
+
+#[post("/accounts/verify-password", data = "<data>")]
+fn verify_password(data: JsonUpcase<VerifyPasswordData>, headers: Headers, _conn: DbConn) -> EmptyResult {
+ let data: VerifyPasswordData = data.into_inner().data;
+ let user = headers.user;
+
+ if !user.check_valid_password(&data.MasterPasswordHash) {
+ err!("Invalid password")
+ }
+
+ Ok(())
+}