From 02b62fb1d042178ae9201d4767a3b92dcf830495 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Mon, 9 Aug 2021 12:23:06 +0530 Subject: [PATCH] demo user banner --- config/default.toml | 2 +- src/demo.rs | 2 +- templates/auth/css/main.scss | 12 +++++++++++- templates/auth/css/mobile.scss | 4 ++++ templates/auth/demo-user-banner.html | 12 ++++++++++++ templates/auth/login/index.html | 1 + templates/auth/register/index.html | 1 + templates/components/details-footer/mobile.scss | 4 ++++ 8 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 templates/auth/demo-user-banner.html diff --git a/config/default.toml b/config/default.toml index b78061ba..fef9b3f3 100644 --- a/config/default.toml +++ b/config/default.toml @@ -1,7 +1,7 @@ debug = true source_code = "https://github.com/mCaptcha/mCaptcha" commercial = false -allow_demo = false +allow_demo = true allow_registration = true [server] diff --git a/src/demo.rs b/src/demo.rs index 3c1d4a89..e50eecee 100644 --- a/src/demo.rs +++ b/src/demo.rs @@ -14,7 +14,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - use std::time::Duration; use actix::clock::sleep; @@ -55,6 +54,7 @@ async fn delete_demo_user(data: &AppData) -> ServiceResult<()> { pub async fn run(data: AppData, duration: Duration) -> ServiceResult<()> { register_demo_user(&data).await?; + let fut = async move { loop { sleep(duration).await; diff --git a/templates/auth/css/main.scss b/templates/auth/css/main.scss index db27ab10..62462f1a 100644 --- a/templates/auth/css/main.scss +++ b/templates/auth/css/main.scss @@ -47,14 +47,24 @@ body { position: relative; } -.auth__secondary-action__banner { +@mixin auth__secondary-action__banner-base { display: block; margin: auto; text-align: center; width: 80%; +} + +.auth__secondary-action__banner { + @include auth__secondary-action__banner-base; margin: 20px auto auto auto; } +.auth__demo-user__banner { + @include auth__secondary-action__banner-base; + margin: 5px auto auto auto; + font-size: 0.7rem; +} + .auth__secondary-action__link { text-decoration: none; color: $blue-link; diff --git a/templates/auth/css/mobile.scss b/templates/auth/css/mobile.scss index 81b20b0b..c9b87619 100644 --- a/templates/auth/css/mobile.scss +++ b/templates/auth/css/mobile.scss @@ -42,3 +42,7 @@ body { .auth__logo { width: 120px; } + +.auth__demo-user__cred{ + display: block; +} diff --git a/templates/auth/demo-user-banner.html b/templates/auth/demo-user-banner.html new file mode 100644 index 00000000..91aaee21 --- /dev/null +++ b/templates/auth/demo-user-banner.html @@ -0,0 +1,12 @@ +<. if crate::SETTINGS.allow_demo && crate::SETTINGS.allow_registration { .> +

+ Try mCaptcha without joining +
+ + user: <.= crate::demo::DEMO_USER .> + + + password: <.= crate::demo::DEMO_PASSWORD .> + +

+<. } .> diff --git a/templates/auth/login/index.html b/templates/auth/login/index.html index 053e0fb4..9b558572 100644 --- a/templates/auth/login/index.html +++ b/templates/auth/login/index.html @@ -46,5 +46,6 @@ Create an account

+ <. include!("../demo-user-banner.html"); .> <. include!("../../components/footers.html"); .> diff --git a/templates/auth/register/index.html b/templates/auth/register/index.html index f27a82b6..bdf24305 100644 --- a/templates/auth/register/index.html +++ b/templates/auth/register/index.html @@ -72,5 +72,6 @@ Already have an account? Log in

+ <. include!("../demo-user-banner.html"); .> <. include!("../../components/footers.html"); .> diff --git a/templates/components/details-footer/mobile.scss b/templates/components/details-footer/mobile.scss index 0c212311..433216c2 100644 --- a/templates/components/details-footer/mobile.scss +++ b/templates/components/details-footer/mobile.scss @@ -27,3 +27,7 @@ $footer-font-size: 14px; flex: 1; margin: auto; } + +.details { + margin: auto; +}