mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 14:21:19 +00:00
api.site: check for existing site before creating
This commit is contained in:
parent
5c6258390c
commit
d0fefca6f9
1 changed files with 8 additions and 0 deletions
|
@ -141,6 +141,12 @@ impl Perform for CreateSite {
|
|||
) -> Result<SiteResponse, LemmyError> {
|
||||
let data: &CreateSite = &self;
|
||||
|
||||
match blocking(context.pool(), move |conn| { Site::read(conn, 1)}).await?
|
||||
{
|
||||
Ok(_site) => return Err(APIError::err("site_already_exists").into()),
|
||||
Err(_e) => (),
|
||||
};
|
||||
|
||||
let user = get_user_from_jwt(&data.auth, context.pool()).await?;
|
||||
|
||||
check_slurs(&data.name)?;
|
||||
|
@ -489,6 +495,8 @@ impl Perform for TransferSite {
|
|||
let data: &TransferSite = &self;
|
||||
let mut user = get_user_from_jwt(&data.auth, context.pool()).await?;
|
||||
|
||||
is_admin(context.pool(), user.id).await?;
|
||||
|
||||
// TODO add a User_::read_safe() for this.
|
||||
user.password_encrypted = "".to_string();
|
||||
user.private_key = None;
|
||||
|
|
Loading…
Reference in a new issue