mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-25 16:17:56 +01:00
Implement changes from fabaccess-api#24
This commit is contained in:
parent
047f7bc1de
commit
3300105082
@ -1 +1 @@
|
|||||||
Subproject commit aa006507c48ac734fd09d524d0c84736b0147338
|
Subproject commit aea03aabe3d1322892c1896ba757ceeedb92ed73
|
@ -82,7 +82,7 @@ pub mod machine {
|
|||||||
::capnp::traits::FromU16::from_u16(self.reader.get_data_field::<u16>(0))
|
::capnp::traits::FromU16::from_u16(self.reader.get_data_field::<u16>(0))
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_manager(self) -> ::capnp::Result<crate::schema::user_capnp::user::Reader<'a>> {
|
pub fn get_manager(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Reader<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(4), ::core::option::Option::None)
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(4), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
pub fn has_manager(&self) -> bool {
|
pub fn has_manager(&self) -> bool {
|
||||||
@ -256,15 +256,15 @@ pub mod machine {
|
|||||||
self.builder.set_data_field::<u16>(0, value as u16)
|
self.builder.set_data_field::<u16>(0, value as u16)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_manager(self) -> ::capnp::Result<crate::schema::user_capnp::user::Builder<'a>> {
|
pub fn get_manager(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(4), ::core::option::Option::None)
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(4), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_manager(&mut self, value: crate::schema::user_capnp::user::Reader<'_>) -> ::capnp::Result<()> {
|
pub fn set_manager(&mut self, value: crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned>) -> ::capnp::Result<()> {
|
||||||
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(4), value, false)
|
<crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned> as ::capnp::traits::SetPointerBuilder>::set_pointer_builder(self.builder.get_pointer_field(4), value, false)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_manager(self, ) -> crate::schema::user_capnp::user::Builder<'a> {
|
pub fn init_manager(self, ) -> crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(4), 0)
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(4), 0)
|
||||||
}
|
}
|
||||||
pub fn has_manager(&self) -> bool {
|
pub fn has_manager(&self) -> bool {
|
||||||
@ -383,7 +383,7 @@ pub mod machine {
|
|||||||
pub fn get_space(&self) -> crate::schema::space_capnp::space::Pipeline {
|
pub fn get_space(&self) -> crate::schema::space_capnp::space::Pipeline {
|
||||||
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
|
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
|
||||||
}
|
}
|
||||||
pub fn get_manager(&self) -> crate::schema::user_capnp::user::Pipeline {
|
pub fn get_manager(&self) -> crate::schema::general_capnp::optional::Pipeline<crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(4))
|
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(4))
|
||||||
}
|
}
|
||||||
pub fn get_info(&self) -> crate::schema::machine_capnp::machine::info::Client {
|
pub fn get_info(&self) -> crate::schema::machine_capnp::machine::info::Client {
|
||||||
@ -496,21 +496,21 @@ pub mod machine {
|
|||||||
self.reader.total_size()
|
self.reader.total_size()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_current_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Reader<'a>> {
|
pub fn get_current_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Reader<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
pub fn has_current_user(&self) -> bool {
|
pub fn has_current_user(&self) -> bool {
|
||||||
!self.reader.get_pointer_field(0).is_null()
|
!self.reader.get_pointer_field(0).is_null()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_last_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Reader<'a>> {
|
pub fn get_last_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Reader<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None)
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
pub fn has_last_user(&self) -> bool {
|
pub fn has_last_user(&self) -> bool {
|
||||||
!self.reader.get_pointer_field(1).is_null()
|
!self.reader.get_pointer_field(1).is_null()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_instructor_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Reader<'a>> {
|
pub fn get_instructor_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Reader<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None)
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
pub fn has_instructor_user(&self) -> bool {
|
pub fn has_instructor_user(&self) -> bool {
|
||||||
@ -567,45 +567,45 @@ pub mod machine {
|
|||||||
self.builder.into_reader().total_size()
|
self.builder.into_reader().total_size()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_current_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Builder<'a>> {
|
pub fn get_current_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_current_user(&mut self, value: crate::schema::user_capnp::user::Reader<'_>) -> ::capnp::Result<()> {
|
pub fn set_current_user(&mut self, value: crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned>) -> ::capnp::Result<()> {
|
||||||
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value, false)
|
<crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned> as ::capnp::traits::SetPointerBuilder>::set_pointer_builder(self.builder.get_pointer_field(0), value, false)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_current_user(self, ) -> crate::schema::user_capnp::user::Builder<'a> {
|
pub fn init_current_user(self, ) -> crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0)
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0)
|
||||||
}
|
}
|
||||||
pub fn has_current_user(&self) -> bool {
|
pub fn has_current_user(&self) -> bool {
|
||||||
!self.builder.get_pointer_field(0).is_null()
|
!self.builder.get_pointer_field(0).is_null()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_last_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Builder<'a>> {
|
pub fn get_last_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None)
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_last_user(&mut self, value: crate::schema::user_capnp::user::Reader<'_>) -> ::capnp::Result<()> {
|
pub fn set_last_user(&mut self, value: crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned>) -> ::capnp::Result<()> {
|
||||||
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value, false)
|
<crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned> as ::capnp::traits::SetPointerBuilder>::set_pointer_builder(self.builder.get_pointer_field(1), value, false)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_last_user(self, ) -> crate::schema::user_capnp::user::Builder<'a> {
|
pub fn init_last_user(self, ) -> crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
|
||||||
}
|
}
|
||||||
pub fn has_last_user(&self) -> bool {
|
pub fn has_last_user(&self) -> bool {
|
||||||
!self.builder.get_pointer_field(1).is_null()
|
!self.builder.get_pointer_field(1).is_null()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_instructor_user(self) -> ::capnp::Result<crate::schema::user_capnp::user::Builder<'a>> {
|
pub fn get_instructor_user(self) -> ::capnp::Result<crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned>> {
|
||||||
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None)
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_instructor_user(&mut self, value: crate::schema::user_capnp::user::Reader<'_>) -> ::capnp::Result<()> {
|
pub fn set_instructor_user(&mut self, value: crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned>) -> ::capnp::Result<()> {
|
||||||
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(2), value, false)
|
<crate::schema::general_capnp::optional::Reader<'_,crate::schema::user_capnp::user::Owned> as ::capnp::traits::SetPointerBuilder>::set_pointer_builder(self.builder.get_pointer_field(2), value, false)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_instructor_user(self, ) -> crate::schema::user_capnp::user::Builder<'a> {
|
pub fn init_instructor_user(self, ) -> crate::schema::general_capnp::optional::Builder<'a,crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), 0)
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), 0)
|
||||||
}
|
}
|
||||||
pub fn has_instructor_user(&self) -> bool {
|
pub fn has_instructor_user(&self) -> bool {
|
||||||
@ -620,13 +620,13 @@ pub mod machine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Pipeline {
|
impl Pipeline {
|
||||||
pub fn get_current_user(&self) -> crate::schema::user_capnp::user::Pipeline {
|
pub fn get_current_user(&self) -> crate::schema::general_capnp::optional::Pipeline<crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(0))
|
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(0))
|
||||||
}
|
}
|
||||||
pub fn get_last_user(&self) -> crate::schema::user_capnp::user::Pipeline {
|
pub fn get_last_user(&self) -> crate::schema::general_capnp::optional::Pipeline<crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
|
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
|
||||||
}
|
}
|
||||||
pub fn get_instructor_user(&self) -> crate::schema::user_capnp::user::Pipeline {
|
pub fn get_instructor_user(&self) -> crate::schema::general_capnp::optional::Pipeline<crate::schema::user_capnp::user::Owned> {
|
||||||
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(2))
|
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,8 +208,8 @@ impl ManageServer for Machine {
|
|||||||
) -> Promise<(), ::capnp::Error> {
|
) -> Promise<(), ::capnp::Error> {
|
||||||
let mut builder = result.get();
|
let mut builder = result.get();
|
||||||
let user = User::new_self(self.session.clone());
|
let user = User::new_self(self.session.clone());
|
||||||
user.build_else(self.resource.get_current_user(), builder.reborrow().init_current_user());
|
user.build_optional(self.resource.get_current_user(), builder.reborrow().init_current_user());
|
||||||
user.build_else(self.resource.get_previous_user(), builder.init_last_user());
|
user.build_optional(self.resource.get_previous_user(), builder.init_last_user());
|
||||||
Promise::ok(())
|
Promise::ok(())
|
||||||
}
|
}
|
||||||
fn set_property(
|
fn set_property(
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use capnp::capability::Promise;
|
use capnp::capability::Promise;
|
||||||
use capnp_rpc::pry;
|
use capnp_rpc::pry;
|
||||||
use crate::session::SessionHandle;
|
use crate::session::SessionHandle;
|
||||||
use api::user_capnp::user::{admin, info, manage, Builder};
|
use api::user_capnp::user::{admin, info, manage, self};
|
||||||
|
use api::general_capnp::optional;
|
||||||
use crate::authorization::permissions::Permission;
|
use crate::authorization::permissions::Permission;
|
||||||
use crate::users::{db, UserRef};
|
use crate::users::{db, UserRef};
|
||||||
|
|
||||||
@ -21,19 +22,20 @@ impl User {
|
|||||||
Self::new(session, user)
|
Self::new(session, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_else(&self, user: Option<UserRef>, builder: Builder) {
|
pub fn build_optional(&self, user: Option<UserRef>, builder: optional::Builder<user::Owned>) {
|
||||||
if let Some(user) = user.and_then(|u| self.session.users.get_user(u.get_username())) {
|
if let Some(user) = user.and_then(|u| self.session.users.get_user(u.get_username())) {
|
||||||
|
let mut builder = builder.init_just();
|
||||||
self.fill(user, builder);
|
self.fill(user, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(session: SessionHandle, mut builder: Builder) {
|
pub fn build(session: SessionHandle, mut builder: user::Builder) {
|
||||||
let this = Self::new_self(session);
|
let this = Self::new_self(session);
|
||||||
let user = this.session.get_user();
|
let user = this.session.get_user();
|
||||||
this.fill(user, builder);
|
this.fill(user, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill(&self, user: db::User, mut builder: Builder) {
|
pub fn fill(&self, user: db::User, mut builder: user::Builder) {
|
||||||
builder.set_username(user.id.as_str());
|
builder.set_username(user.id.as_str());
|
||||||
|
|
||||||
let client = Self::new(self.session.clone(), UserRef::new(user.id.clone()));
|
let client = Self::new(self.session.clone(), UserRef::new(user.id.clone()));
|
||||||
|
Loading…
Reference in New Issue
Block a user