diff --git a/src/dispatch/auth/models.py b/src/dispatch/auth/models.py index 4b7d4ecfa106..40e4488dcf98 100644 --- a/src/dispatch/auth/models.py +++ b/src/dispatch/auth/models.py @@ -89,6 +89,7 @@ class DispatchUserOrganization(Base, TimeStampMixin): organization_id = Column(Integer, ForeignKey(Organization.id), primary_key=True) organization = relationship(Organization, backref="users") + default = Column(Boolean, default=False) role = Column(String, default=UserRoles.member) @@ -100,7 +101,6 @@ class DispatchUserProject(Base, TimeStampMixin): project = relationship(Project, backref="users") default = Column(Boolean, default=False) - role = Column(String, nullable=False, default=UserRoles.member) @@ -163,7 +163,6 @@ class UserUpdate(DispatchBase): password: Optional[str] = Field(None, nullable=True) projects: Optional[List[UserProject]] organizations: Optional[List[UserOrganization]] - role: Optional[str] = Field(None, nullable=True) @validator("password", pre=True) def hash(cls, v): diff --git a/src/dispatch/auth/views.py b/src/dispatch/auth/views.py index 5be6e6898175..404d67be4e73 100644 --- a/src/dispatch/auth/views.py +++ b/src/dispatch/auth/views.py @@ -104,8 +104,11 @@ def update_user( detail=[{"msg": "A user with this id does not exist."}], ) - if user_in.role: - user_organization_role = user.get_organization_role(organization) + # allow considerations for updating their own preferences + user_organization_role = user.get_organization_role(organization) + if current_user.id == user_id: + pass + else: if user_organization_role != user_in.role: current_user_organization_role = current_user.get_organization_role(organization) if current_user_organization_role != UserRoles.owner: @@ -118,11 +121,6 @@ def update_user( ], ) - # add organization information - user_in.organizations = [ - UserOrganization(role=user_in.role, organization=OrganizationRead(name=organization)) - ] - return update(db_session=db_session, user=user, user_in=user_in) diff --git a/src/dispatch/static/dispatch/src/App.vue b/src/dispatch/static/dispatch/src/App.vue index 250354fcd8ea..e8e1cdfb12e6 100644 --- a/src/dispatch/static/dispatch/src/App.vue +++ b/src/dispatch/static/dispatch/src/App.vue @@ -1,7 +1,7 @@