add: littleweb (common) achievements
This commit is contained in:
parent
7960f1ed41
commit
4e152b07be
3 changed files with 30 additions and 3 deletions
|
@ -6,6 +6,7 @@ use crate::{
|
|||
use axum::{extract::Path, response::IntoResponse, http::StatusCode, Extension, Json};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use tetratto_core::model::{
|
||||
auth::AchievementName,
|
||||
littleweb::{Domain, ServiceFsMime},
|
||||
oauth, ApiReturn, Error,
|
||||
};
|
||||
|
@ -48,11 +49,20 @@ pub async fn create_request(
|
|||
Json(req): Json<CreateDomain>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreateDomains) {
|
||||
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreateDomains) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
// award achievement
|
||||
if let Err(e) = data
|
||||
.add_achievement(&mut user, AchievementName::CreateDomain.into(), true)
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
|
||||
// ...
|
||||
match data
|
||||
.create_domain(Domain::new(req.name, req.tld, user.id))
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue