From ddd49596ba037d04dfc8b2e8fa21fe14951feb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 22 Jan 2019 17:26:17 +0100 Subject: [PATCH] Fix invite empty email --- src/db/models/user.rs | 8 ++++++++ src/static/templates/admin/page.hbs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/db/models/user.rs b/src/db/models/user.rs index 888d3f57..02254326 100644 --- a/src/db/models/user.rs +++ b/src/db/models/user.rs @@ -137,6 +137,10 @@ impl User { } pub fn save(&mut self, conn: &DbConn) -> EmptyResult { + if self.email.trim().is_empty() { + err!("User email can't be empty") + } + self.updated_at = Utc::now().naive_utc(); diesel::replace_into(users::table) // Insert or update @@ -213,6 +217,10 @@ impl Invitation { } pub fn save(&mut self, conn: &DbConn) -> EmptyResult { + if self.email.trim().is_empty() { + err!("Invitation email can't be empty") + } + diesel::replace_into(invitations::table) .values(&*self) .execute(&**conn) diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs index 8847f5be..538eda8e 100644 --- a/src/static/templates/admin/page.hbs +++ b/src/static/templates/admin/page.hbs @@ -65,7 +65,7 @@ } function deleteUser(id, mail) { var input_mail = prompt("To delete user '" + mail + "', please type the name below") - if (input_mail) { + if (input_mail != null) { if (input_mail == mail) { _post("/admin/users/" + id + "/delete", "User deleted correctly",