Libera la versión de desarrollo 0.0.2
This commit is contained in:
parent
516d9683da
commit
fbc6ab2adf
77 changed files with 651 additions and 161 deletions
22
pagetop-user/Cargo.toml
Normal file
22
pagetop-user/Cargo.toml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[package]
|
||||
name = "pagetop-user"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
authors = [
|
||||
"Manuel Cillero <manuel@cillero.es>"
|
||||
]
|
||||
description = """\
|
||||
Allows content to be submitted to the site and displayed on pages.\
|
||||
"""
|
||||
homepage = "https://suitepro.cillero.es/projects/drust"
|
||||
repository = "https://gitlab.com/manuelcillero/drust"
|
||||
|
||||
[dependencies]
|
||||
pagetop = { path = "../pagetop" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
[dependencies.sea-orm]
|
||||
version = "0.6.0"
|
||||
features = ["debug-print", "macros"]
|
||||
default-features = false
|
||||
1
pagetop-user/src/entity/mod.rs
Normal file
1
pagetop-user/src/entity/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod user;
|
||||
18
pagetop-user/src/entity/user.rs
Normal file
18
pagetop-user/src/entity/user.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use crate::db::entity::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "user")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
#[serde(skip_deserializing)]
|
||||
pub id: i32,
|
||||
pub title: String,
|
||||
#[sea_orm(column_type = "Text")]
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
59
pagetop-user/src/lib.rs
Normal file
59
pagetop-user/src/lib.rs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
localize!("src/locales");
|
||||
|
||||
mod entity;
|
||||
mod migration;
|
||||
|
||||
pub struct UserModule;
|
||||
|
||||
impl ModuleTrait for UserModule {
|
||||
fn fullname(&self) -> String {
|
||||
l("module_fullname")
|
||||
}
|
||||
|
||||
fn description(&self) -> Option<String> {
|
||||
Some(l("module_description"))
|
||||
}
|
||||
|
||||
fn configure_module(&self, cfg: &mut app::web::ServiceConfig) {
|
||||
cfg.route("/user/login", app::web::get().to(login));
|
||||
}
|
||||
|
||||
fn migrations(&self) -> Vec<Box<dyn db::migration::MigrationTrait>> {
|
||||
vec![
|
||||
boxed_migration!(m20220312_000001_create_table_user)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
fn form_login() -> impl PageComponent {
|
||||
Form::prepare()
|
||||
.with_id("user-login")
|
||||
.add(form::Input::textfield()
|
||||
.with_name("name")
|
||||
.with_label(l("username").as_str())
|
||||
.with_help_text(t("username_help", &args![
|
||||
"app" => SETTINGS.app.name.to_owned()
|
||||
]).as_str())
|
||||
.autofocus(true)
|
||||
)
|
||||
.add(form::Input::password()
|
||||
.with_name("pass")
|
||||
.with_label(l("password").as_str())
|
||||
.with_help_text(l("password_help").as_str())
|
||||
)
|
||||
.add(form::Button::submit(l("login").as_str()))
|
||||
}
|
||||
|
||||
async fn login() -> app::Result<Markup> {
|
||||
Page::prepare()
|
||||
.with_title(
|
||||
"Identificación del usuario"
|
||||
)
|
||||
.add_to("content", Container::prepare()
|
||||
.with_id("welcome")
|
||||
.add(form_login())
|
||||
)
|
||||
.render()
|
||||
}
|
||||
8
pagetop-user/src/locales/en-US/homepage.ftl
Normal file
8
pagetop-user/src/locales/en-US/homepage.ftl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module_fullname = User
|
||||
module_description = Manages the user registration and login system.
|
||||
|
||||
username = User name
|
||||
password = Password
|
||||
username_help = Enter your { $app } username.
|
||||
password_help = Enter the password that accompanies your username.
|
||||
login = Log in
|
||||
8
pagetop-user/src/locales/es-ES/homepage.ftl
Normal file
8
pagetop-user/src/locales/es-ES/homepage.ftl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module_fullname = Usuario
|
||||
module_description = Gestion el registro de usuarios y el sistema de accesos.
|
||||
|
||||
username = Nombre de usuario
|
||||
password = Contraseña
|
||||
username_help = Introduzca su nombre de usuario en { $app }.
|
||||
password_help = Introduzca la contraseña asociada a su nombre de usuario.
|
||||
login = Iniciar sesión
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
use crate::db::migration::*;
|
||||
|
||||
#[derive(Iden)]
|
||||
enum User {
|
||||
Table,
|
||||
Id,
|
||||
Title,
|
||||
Text,
|
||||
}
|
||||
|
||||
pub struct Migration;
|
||||
|
||||
impl MigrationName for Migration {
|
||||
fn name(&self) -> &str {
|
||||
"m20220312_000001_create_table_user"
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(User::Table)
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(User::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(User::Title)
|
||||
.string()
|
||||
.not_null()
|
||||
)
|
||||
.col(ColumnDef::new(User::Text)
|
||||
.string()
|
||||
.not_null()
|
||||
)
|
||||
.to_owned()
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop()
|
||||
.table(User::Table)
|
||||
.to_owned()
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
1
pagetop-user/src/migration/mod.rs
Normal file
1
pagetop-user/src/migration/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod m20220312_000001_create_table_user;
|
||||
Loading…
Add table
Add a link
Reference in a new issue