merge upstream
All checks were successful
mnemo-build-and-publish / gractwo-mnemo-build (push) Successful in 31s
All checks were successful
mnemo-build-and-publish / gractwo-mnemo-build (push) Successful in 31s
This commit is contained in:
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
persons::Person,
|
||||
users::{
|
||||
User,
|
||||
@@ -95,6 +96,13 @@ pub async fn create(
|
||||
Form(form): Form<PersonNameForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let u = User::authenticate(&headers)?.required()?;
|
||||
Person::create(form.primary_name, u.id)?;
|
||||
let p = Person::create(form.primary_name, u.id)?;
|
||||
LogEntry::new(
|
||||
u,
|
||||
LogAction::CreatePerson {
|
||||
id: p.id,
|
||||
pname: p.primary_name,
|
||||
},
|
||||
)?;
|
||||
Ok(Redirect::to("/persons").into_response())
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
tags::{Tag, TagName},
|
||||
users::{
|
||||
User,
|
||||
@@ -94,7 +95,14 @@ pub async fn create(
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<TagForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
User::authenticate(&headers)?.required()?;
|
||||
Tag::create(form.tagname)?;
|
||||
let u = User::authenticate(&headers)?.required()?;
|
||||
let t = Tag::create(form.tagname)?;
|
||||
LogEntry::new(
|
||||
u,
|
||||
LogAction::CreateTag {
|
||||
id: t.id,
|
||||
name: t.name.to_string(),
|
||||
},
|
||||
)?;
|
||||
Ok(Redirect::to("/tags").into_response())
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
users::{
|
||||
User,
|
||||
auth::{AuthError, UserAuthRequired, UserAuthenticate},
|
||||
@@ -75,5 +76,12 @@ pub async fn create_user(
|
||||
}
|
||||
let mut nu = User::create(form.handle)?;
|
||||
nu.set_password(Some(&form.password))?;
|
||||
LogEntry::new(
|
||||
u,
|
||||
LogAction::CreateUser {
|
||||
id: nu.id,
|
||||
handle: nu.handle.as_str().to_string(),
|
||||
},
|
||||
)?;
|
||||
Ok(Redirect::to("/users").into_response())
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
users::{
|
||||
User,
|
||||
auth::{AuthError, UserAuthRequired, UserAuthenticate},
|
||||
@@ -80,7 +81,16 @@ pub async fn change_handle(
|
||||
Form(form): Form<HandleForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut u = User::authenticate(&headers)?.required()?;
|
||||
let oldhandle = u.handle.as_str().to_string();
|
||||
u.set_handle(form.handle)?;
|
||||
LogEntry::new(
|
||||
u.clone(),
|
||||
LogAction::ChangeUserHandle {
|
||||
id: u.id,
|
||||
old: oldhandle,
|
||||
new: u.handle.as_str().to_string(),
|
||||
},
|
||||
)?;
|
||||
Ok(Redirect::to("/user-settings").into_response())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user