From 558dbef7127331b2b31b0d87ddf921e1d34a2447 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 13 Jul 2021 21:23:08 +0530 Subject: [PATCH] dupe email check and notifications table --- src/api/v1/auth.rs | 2 +- src/api/v1/tests/auth.rs | 14 ++++- templates/panel/notifications/index.html | 58 +++++++++++-------- .../panel/sitekey/add/existing-level.html | 1 - templates/panel/sitekey/list/index.html | 10 +--- 5 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/api/v1/auth.rs b/src/api/v1/auth.rs index 42648989..8794d963 100644 --- a/src/api/v1/auth.rs +++ b/src/api/v1/auth.rs @@ -182,7 +182,7 @@ pub mod runners { if msg.contains("mcaptcha_users_name_key") { return Err(ServiceError::UsernameTaken); } else if msg.contains("mcaptcha_users_email_key") { - return Err(ServiceError::UsernameTaken); + return Err(ServiceError::EmailTaken); } else if msg.contains("mcaptcha_users_secret_key") { continue; } else { diff --git a/src/api/v1/tests/auth.rs b/src/api/v1/tests/auth.rs index e4df6475..edd66ee1 100644 --- a/src/api/v1/tests/auth.rs +++ b/src/api/v1/tests/auth.rs @@ -59,7 +59,7 @@ async fn auth_works() { signin(EMAIL, PASSWORD).await; // 2. check if duplicate username is allowed - let msg = Register { + let mut msg = Register { username: NAME.into(), password: PASSWORD.into(), confirm_password: PASSWORD.into(), @@ -75,6 +75,18 @@ async fn auth_works() { ) .await; + let name = format!("{}dupemail", NAME); + msg.username = name; + bad_post_req_test( + NAME, + PASSWORD, + ROUTES.auth.register, + &msg, + ServiceError::EmailTaken, + StatusCode::BAD_REQUEST, + ) + .await; + // 3. sigining in with non-existent user let mut creds = Login { login: "nonexistantuser".into(), diff --git a/templates/panel/notifications/index.html b/templates/panel/notifications/index.html index 147d7958..c832150f 100644 --- a/templates/panel/notifications/index.html +++ b/templates/panel/notifications/index.html @@ -1,24 +1,36 @@ -<. include!("../../components/headers/index.html"); .> -<. include!("../navbar/index.html"); .> +<. include!("../../components/headers/index.html"); .> <. +include!("../navbar/index.html"); .>
-<. include!("../header/index.html"); .> - -
- -
- - -
    -

    Your Notifications

    - <. for notification in n.iter() { .> -
  • -

    <.= notification.heading .>

    -

    From: <.= notification.name .>

    -

    Received: <.= notification.received .>

    -

    Message: <.= notification.message .>

    - <. } .> -
- -
- -<. include!("../../components/footers.html"); .> + <. include!("../header/index.html"); .> +
+ +
+ + + + + + + <. for notification in n.iter() { .> + + + + + + + <. } .> + +
Your Notifications
+ + +

+ <.= notification.heading .> +

+

<.= notification.message .>

+
<.= notification.name .><.= notification.received .>
+
+ + <. include!("../../components/footers.html"); .> +
+ + diff --git a/templates/panel/sitekey/add/existing-level.html b/templates/panel/sitekey/add/existing-level.html index 62f0e5f3..fc7677f3 100644 --- a/templates/panel/sitekey/add/existing-level.html +++ b/templates/panel/sitekey/add/existing-level.html @@ -12,7 +12,6 @@ id="visitor<.= level .>" /> -