init commit
This commit is contained in:
41
src/views/auth.rs
Normal file
41
src/views/auth.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::models::_entities::users;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct LoginResponse {
|
||||
pub token: String,
|
||||
pub pid: String,
|
||||
pub name: String,
|
||||
pub is_verified: bool,
|
||||
}
|
||||
|
||||
impl LoginResponse {
|
||||
#[must_use]
|
||||
pub fn new(user: &users::Model, token: &String) -> Self {
|
||||
Self {
|
||||
token: token.to_string(),
|
||||
pid: user.pid.to_string(),
|
||||
name: user.name.clone(),
|
||||
is_verified: user.email_verified_at.is_some(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct CurrentResponse {
|
||||
pub pid: String,
|
||||
pub name: String,
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
impl CurrentResponse {
|
||||
#[must_use]
|
||||
pub fn new(user: &users::Model) -> Self {
|
||||
Self {
|
||||
pid: user.pid.to_string(),
|
||||
name: user.name.clone(),
|
||||
email: user.email.clone(),
|
||||
}
|
||||
}
|
||||
}
|
2
src/views/mod.rs
Normal file
2
src/views/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod auth;
|
||||
pub mod website;
|
14
src/views/website.rs
Normal file
14
src/views/website.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use loco_rs::prelude::*;
|
||||
|
||||
use crate::services;
|
||||
|
||||
pub async fn index(v: impl ViewRenderer, ctx: &AppContext) -> Result<impl IntoResponse> {
|
||||
let skills = services::skills::get_all_skills(ctx).await?;
|
||||
let jobs = services::jobs::get_all_jobs_with_technologies(ctx).await?;
|
||||
|
||||
format::render().view(
|
||||
&v,
|
||||
"website/index.html",
|
||||
data!({ "skills": skills, "jobs": jobs }),
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user