add: user last_policy_consent
This commit is contained in:
parent
befd9096b1
commit
2edef9bd35
11 changed files with 107 additions and 9 deletions
|
@ -190,7 +190,7 @@ pub async fn stripe_webhook(
|
|||
return Json(e.into());
|
||||
}
|
||||
|
||||
if data.0.0.security.enable_invite_codes && user.awaiting_purchase {
|
||||
if user.awaiting_purchase {
|
||||
if let Err(e) = data
|
||||
.update_user_awaiting_purchased_status(user.id, false, user.clone(), false)
|
||||
.await
|
||||
|
|
|
@ -84,7 +84,6 @@ pub async fn register_request(
|
|||
|
||||
// ...
|
||||
let mut user = User::new(props.username.to_lowercase(), props.password);
|
||||
user.settings.policy_consent = true;
|
||||
|
||||
// check invite code
|
||||
if data.0.0.security.enable_invite_codes {
|
||||
|
|
|
@ -112,6 +112,29 @@ pub async fn me_request(jar: CookieJar, Extension(data): Extension<State>) -> im
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn policy_consent_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data
|
||||
.update_user_last_policy_consent(user.id, unix_epoch_timestamp() as i64)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Consent given".to_string(),
|
||||
payload: Some(user),
|
||||
}),
|
||||
Err(e) => Json(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the settings of the given user.
|
||||
pub async fn update_user_settings_request(
|
||||
jar: CookieJar,
|
||||
|
|
|
@ -302,6 +302,10 @@ pub fn routes() -> Router {
|
|||
)
|
||||
// profile
|
||||
.route("/auth/user/me", get(auth::profile::me_request))
|
||||
.route(
|
||||
"/auth/user/me/policy_consent",
|
||||
post(auth::profile::policy_consent_request),
|
||||
)
|
||||
.route("/auth/user/{id}/avatar", get(auth::images::avatar_request))
|
||||
.route("/auth/user/{id}/banner", get(auth::images::banner_request))
|
||||
.route("/auth/user/{id}/follow", post(auth::social::follow_request))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue