mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Can create new accounts
This commit is contained in:
@ -137,6 +137,13 @@ impl HttpRequestHandler {
|
||||
Err(Box::new(ExecError::new(&message)))
|
||||
}
|
||||
|
||||
/// Conflict (409)
|
||||
pub fn conflict(&mut self, message: String) -> RequestResult {
|
||||
self.response = Some(HttpResponse::Conflict().json(
|
||||
HttpError::new(409, &message)));
|
||||
Err(Box::new(ExecError::new(&message)))
|
||||
}
|
||||
|
||||
/// If result is not OK, return a bad request
|
||||
pub fn ok_or_bad_request<E>(&mut self, res: ResultBoxError<E>, msg: &str) -> ResultBoxError<E> {
|
||||
match res {
|
||||
@ -595,12 +602,10 @@ impl HttpRequestHandler {
|
||||
)?;
|
||||
|
||||
if comment.user_id != self.user_id_or_invalid() {
|
||||
|
||||
let post = posts_helper::get_single(comment.post_id)?;
|
||||
if posts_helper::get_access_level(&post, &self.user_id_opt())? == PostAccessLevel::NO_ACCESS {
|
||||
self.forbidden("You are not allowed to access this post information !".to_string())?;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Ok(comment)
|
||||
|
@ -25,4 +25,5 @@ pub mod survey;
|
||||
pub mod comment;
|
||||
pub mod new_survey;
|
||||
pub mod notification;
|
||||
pub mod user_membership;
|
||||
pub mod user_membership;
|
||||
pub mod new_account;
|
10
src/data/new_account.rs
Normal file
10
src/data/new_account.rs
Normal file
@ -0,0 +1,10 @@
|
||||
//! # New account
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
pub struct NewAccount {
|
||||
pub first_name: String,
|
||||
pub last_name: String,
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
Reference in New Issue
Block a user