-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ee075b
commit 209f56c
Showing
2 changed files
with
170 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,120 +2,128 @@ import { ChevronRightIcon } from "@heroicons/react/24/solid"; | |
import logo from "../assets/logo_only.svg"; | ||
function Dashboard() { | ||
return ( | ||
<div className="relative sm:flex sm:justify-center sm:items-center min-h-screen bg-center bg-gray-100 selection:bg-primary-500 selection:text-white"> | ||
<div className="max-w-7xl mx-auto p-6 lg:p-8"> | ||
<div className="flex justify-center"> | ||
<img src={logo} className="w-20 h-20" alt="Avored Rust Cms" /> | ||
<div className="relative sm:flex sm:justify-center sm:items-center min-h-screen bg-center bg-gray-100 selection:bg-primary-500 selection:text-white"> | ||
<div className="max-w-7xl mx-auto p-6 lg:p-8"> | ||
<div className="flex justify-center"> | ||
<img src={logo} className="w-20 h-20" alt="Avored Rust Cms" /> | ||
</div> | ||
<div className="mt-16"> | ||
<div className="flex justify-center"> | ||
<div className="text-gray-600"> | ||
To Access demo admin please use the email: [email protected] and password: admin123 | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="mt-16"> | ||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-8"> | ||
<a | ||
href="/admin/login" | ||
className="scale-100 p-6 bg-white rounded-lg shadow-2xl shadow-gray-500/20 flex focus:outline focus:outline-2 focus:outline-primary-500" | ||
> | ||
<div> | ||
<div className="h-16 w-16 bg-primary-50 flex items-center justify-center rounded-full"> | ||
<i | ||
className="w-7 h-7 stroke-primary-500" | ||
data-feather="framer" | ||
></i> | ||
</div> | ||
|
||
<h2 className="mt-6 text-xl font-semibold text-gray-900"> | ||
Administrator | ||
</h2> | ||
<div className="mt-16"> | ||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-8"> | ||
<a | ||
href="/admin/login" | ||
className="scale-100 p-6 bg-white rounded-lg shadow-2xl shadow-gray-500/20 flex focus:outline focus:outline-2 focus:outline-primary-500" | ||
> | ||
<div> | ||
<div className="h-16 w-16 bg-primary-50 flex items-center justify-center rounded-full"> | ||
<i | ||
className="w-7 h-7 stroke-primary-500" | ||
data-feather="framer" | ||
></i> | ||
</div> | ||
|
||
<p className="mt-4 text-gray-500 text-sm leading-relaxed"> | ||
An app administrator plays a pivotal role in ensuring the | ||
smooth operation of the avored cms. They are responsible for | ||
managing user access, content updates and overseeing updates. | ||
The administrator acts as the gatekeeper, safeguarding the | ||
app's content and user experience while facilitating its | ||
growth and improvement. In essence, they are the backbone of a | ||
well-maintained and secure avored rust cms ecosystem. | ||
</p> | ||
</div> | ||
<div className="self-center pl-5"> | ||
<ChevronRightIcon className="w-6 h-6" /> | ||
</div> | ||
</a> | ||
<h2 className="mt-6 text-xl font-semibold text-gray-900"> | ||
Administrator | ||
</h2> | ||
|
||
<a | ||
href="https://github.com/avored/avored-rust-cms" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="scale-100 p-6 bg-white rounded-lg shadow-2xl flex focus:outline focus:outline-2 focus:outline-primary-500" | ||
> | ||
<div> | ||
<div className="h-16 w-16 bg-primary-50 flex items-center justify-center rounded-full"> | ||
<p className="mt-4 text-gray-500 text-sm leading-relaxed"> | ||
An app administrator plays a pivotal role in ensuring the | ||
smooth operation of the avored cms. They are responsible for | ||
managing user access, content updates and overseeing | ||
updates. The administrator acts as the gatekeeper, | ||
safeguarding the app's content and user experience while | ||
facilitating its growth and improvement. In essence, they | ||
are the backbone of a well-maintained and secure avored rust | ||
cms ecosystem. | ||
</p> | ||
</div> | ||
<div className="self-center pl-5"> | ||
<ChevronRightIcon className="w-6 h-6" /> | ||
</div> | ||
</a> | ||
|
||
<i | ||
className="w-7 h-7 stroke-primary-500" | ||
data-feather="github" | ||
></i> | ||
</div> | ||
<a | ||
href="https://github.com/avored/avored-rust-cms" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="scale-100 p-6 bg-white rounded-lg shadow-2xl flex focus:outline focus:outline-2 focus:outline-primary-500" | ||
> | ||
<div> | ||
<div className="h-16 w-16 bg-primary-50 flex items-center justify-center rounded-full"> | ||
<i | ||
className="w-7 h-7 stroke-primary-500" | ||
data-feather="github" | ||
></i> | ||
</div> | ||
|
||
<h2 className="mt-6 text-xl font-semibold text-gray-900"> | ||
Github | ||
</h2> | ||
<h2 className="mt-6 text-xl font-semibold text-gray-900"> | ||
Github | ||
</h2> | ||
|
||
<p className="mt-4 text-gray-500 text-sm leading-relaxed"> | ||
GitHub Star: When you "star" a GitHub repository, it signifies | ||
your interest in that project. Starring a repository also | ||
sends a signal to the repository owner that you appreciate | ||
their work or find it valuable. Community Help: The GitHub | ||
community is known for its collaborative nature. Developers | ||
frequently help each other by contributing to open-source | ||
projects, reporting issues, suggesting improvements, and even | ||
submitting pull requests to fix bugs or add features. This | ||
collective effort is essential for the growth and success of | ||
open-source projects hosted on GitHub. | ||
</p> | ||
</div> | ||
<p className="mt-4 text-gray-500 text-sm leading-relaxed"> | ||
GitHub Star: When you "star" a GitHub repository, it | ||
signifies your interest in that project. Starring a | ||
repository also sends a signal to the repository owner that | ||
you appreciate their work or find it valuable. Community | ||
Help: The GitHub community is known for its collaborative | ||
nature. Developers frequently help each other by | ||
contributing to open-source projects, reporting issues, | ||
suggesting improvements, and even submitting pull requests | ||
to fix bugs or add features. This collective effort is | ||
essential for the growth and success of open-source projects | ||
hosted on GitHub. | ||
</p> | ||
</div> | ||
|
||
<div className="self-center pl-5"> | ||
<i | ||
className="w-6 h-6 stroke-primary-500" | ||
data-feather="chevrons-right" | ||
></i> | ||
</div> | ||
</a> | ||
</div> | ||
<div className="self-center pl-5"> | ||
<i | ||
className="w-6 h-6 stroke-primary-500" | ||
data-feather="chevrons-right" | ||
></i> | ||
</div> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div className="flex justify-center mt-16 px-0 sm:items-center sm:justify-between"> | ||
<div className="text-center text-sm text-gray-500 sm:text-left"> | ||
<div className="flex items-center gap-4"> | ||
<a | ||
href="https://github.com/sponsors/indpurvesh" | ||
className="group inline-flex items-center hover:text-gray-700 dark:hover:text-white focus:outline focus:outline-2 focus:rounded-sm focus:outline-primary-500" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth="1.5" | ||
className="-mt-px mr-1 w-5 h-5 stroke-gray-400 dark:stroke-gray-600 group-hover:stroke-gray-600 dark:group-hover:stroke-gray-400" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" | ||
/> | ||
</svg> | ||
Sponsor | ||
</a> | ||
</div> | ||
</div> | ||
<div className="flex justify-center mt-16 px-0 sm:items-center sm:justify-between"> | ||
<div className="text-center text-sm text-gray-500 sm:text-left"> | ||
<div className="flex items-center gap-4"> | ||
<a | ||
href="https://github.com/sponsors/indpurvesh" | ||
className="group inline-flex items-center hover:text-gray-700 dark:hover:text-white focus:outline focus:outline-2 focus:rounded-sm focus:outline-primary-500" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth="1.5" | ||
className="-mt-px mr-1 w-5 h-5 stroke-gray-400 dark:stroke-gray-600 group-hover:stroke-gray-600 dark:group-hover:stroke-gray-400" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" | ||
/> | ||
</svg> | ||
Sponsor | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div className="ml-4 text-center text-sm text-gray-500 sm:text-right sm:ml-0"> | ||
AvoRed Rust CMS | ||
</div> | ||
</div> | ||
<div className="ml-4 text-center text-sm text-gray-500 sm:text-right sm:ml-0"> | ||
AvoRed Rust CMS | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Dashboard; | ||
export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use std::collections::BTreeMap; | ||
use std::sync::Arc; | ||
|
||
use argon2::{Argon2, PasswordHasher}; | ||
use argon2::password_hash::SaltString; | ||
use crate::{ | ||
avored_state::AvoRedState, | ||
error::Result, | ||
|
@@ -9,6 +10,8 @@ use axum::{extract::State, Json, response::IntoResponse, Extension}; | |
use serde::Serialize; | ||
use tokio::fs::File; | ||
use tokio::io::AsyncWriteExt; | ||
use crate::models::admin_user_model::CreatableAdminUserModel; | ||
use crate::models::role_model::CreatableRole; | ||
use crate::models::token_claim_model::LoggedInUser; | ||
|
||
pub async fn install_demo_data_api_handler( | ||
|
@@ -236,7 +239,7 @@ pub async fn install_demo_data_api_handler( | |
"; | ||
|
||
let vars = BTreeMap::from([ | ||
("email".into(), logged_in_user.email.into()), | ||
("email".into(), logged_in_user.email.clone().into()), | ||
]); | ||
|
||
let (ds, ses) = &state.db; | ||
|
@@ -249,6 +252,61 @@ pub async fn install_demo_data_api_handler( | |
let mut file = File::create("public/install_demo").await?; | ||
file.write_all(b".gitkeep").await?; | ||
|
||
// @todo create a demo role | ||
// @todo create a demo visitor user | ||
|
||
let demo_role = CreatableRole { | ||
name: "Demo visitor role".to_string(), | ||
identifier: "demo-visitor-role".to_string(), | ||
logged_in_username: logged_in_user.email.clone(), | ||
permissions: vec![ | ||
String::from("dashboard"), | ||
String::from("get_setting"), | ||
String::from("page_table"), | ||
String::from("page_create"), | ||
String::from("page_edit"), | ||
String::from("get_page"), | ||
String::from("page_delete"), | ||
String::from("asset_table"), | ||
String::from("asset_create"), | ||
String::from("asset_edit"), | ||
String::from("asset_delete"), | ||
|
||
], | ||
}; | ||
|
||
let created_role_model = state | ||
.role_service | ||
.create_role(&state.db, demo_role) | ||
.await?; | ||
|
||
let password = "admin123".as_bytes(); | ||
let salt = SaltString::from_b64(&state.config.password_salt)?; | ||
|
||
let argon2 = Argon2::default(); | ||
let password_hash = argon2 | ||
.hash_password(password, &salt) | ||
.expect("Error occurred while encrypted password") | ||
.to_string(); | ||
|
||
let creatable_admin_user = CreatableAdminUserModel { | ||
full_name: "Demo admin user".to_string(), | ||
email: "[email protected]".to_string(), | ||
password: password_hash, | ||
profile_image: "".to_string(), | ||
is_super_admin: false, | ||
logged_in_username: logged_in_user.email.clone(), | ||
role_ids: vec![created_role_model.id], | ||
}; | ||
|
||
let created_admin_user = state | ||
.admin_user_service | ||
.create_admin_user(&state.db, creatable_admin_user, logged_in_user) | ||
.await?; | ||
|
||
|
||
println!("Created admin user: {:?}", created_admin_user); | ||
|
||
let response = DemoDataViewModel { | ||
status: true | ||
}; | ||
|