You've already forked AstralRinth
forked from didirus/AstralRinth
Fix error messages, auth routes, and remove category unique constraint (#293)
* Fix error messages, auth routes, and remove category unique constraint * Run prepare * Remove debug secrets * Fix team member editing
This commit is contained in:
@@ -8,13 +8,12 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{scope, Data, Query, ServiceConfig};
|
||||
use actix_web::{get, HttpResponse};
|
||||
use chrono::Utc;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::postgres::PgPool;
|
||||
use thiserror::Error;
|
||||
|
||||
pub fn config(cfg: &mut ServiceConfig) {
|
||||
cfg.service(scope("/auth/").service(auth_callback).service(init));
|
||||
cfg.service(scope("auth").service(auth_callback).service(init));
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -177,7 +176,7 @@ pub async fn auth_callback(
|
||||
|
||||
let user_result = User::get_from_github_id(user.id, &mut *transaction).await?;
|
||||
match user_result {
|
||||
Some(x) => info!("{:?}", x.id),
|
||||
Some(_) => {}
|
||||
None => {
|
||||
let user_id = crate::database::models::generate_user_id(&mut transaction).await?;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use actix_web::{get, HttpResponse};
|
||||
use serde_json::json;
|
||||
|
||||
#[get("/")]
|
||||
#[get("")]
|
||||
pub async fn index_get() -> HttpResponse {
|
||||
let data = json!({
|
||||
"name": "modrinth-labrinth",
|
||||
|
||||
@@ -280,10 +280,17 @@ pub async fn edit_team_member(
|
||||
"You don't have permission to edit members of this team".to_string(),
|
||||
)
|
||||
})?;
|
||||
let edit_member_db = TeamMember::get_from_user_id(id, user_id, &**pool)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::CustomAuthenticationError(
|
||||
"You don't have permission to edit members of this team".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
if &*member.role == crate::models::teams::OWNER_ROLE {
|
||||
if &*edit_member_db.role == crate::models::teams::OWNER_ROLE {
|
||||
return Err(ApiError::InvalidInputError(
|
||||
"The owner of a team cannot be edited".to_string(),
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user