fix: respect app quota status
This commit is contained in:
parent
39574df691
commit
9bb5f38f76
2 changed files with 14 additions and 2 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
|||
use axum::{Extension, Json, extract::Path, response::IntoResponse};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use tetratto_core::model::{
|
||||
apps::ThirdPartyApp,
|
||||
apps::{AppQuota, ThirdPartyApp},
|
||||
oauth::{AuthGrant, PkceChallengeMethod},
|
||||
permissions::FinePermission,
|
||||
ApiReturn, Error,
|
||||
|
@ -202,6 +202,18 @@ pub async fn grant_request(
|
|||
return Json(Error::MiscError("This app already has a grant".to_string()).into());
|
||||
}
|
||||
|
||||
// check number of existing grants
|
||||
if app.quota_status == AppQuota::Limited && app.grants >= 5 {
|
||||
return Json(
|
||||
Error::MiscError(
|
||||
"This app has reached its limit. Tell the owner to apply for an extension"
|
||||
.to_string(),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
// ...
|
||||
let grant = AuthGrant {
|
||||
app: app.id,
|
||||
challenge: req.challenge,
|
||||
|
|
|
@ -38,7 +38,7 @@ pub enum PkceChallengeMethod {
|
|||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum AppScope {
|
||||
/// Read the profile of other user's on behalf of the user.
|
||||
/// Read the profile of other users on behalf of the user.
|
||||
UserReadProfiles,
|
||||
/// Read the user's profile (username, bio, etc).
|
||||
UserReadProfile,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue