Open platform to collect and prioritize feedback
feature: allow administrators to block/unblock users (#637)
Guilherme Oenninga2c4a25e855c
diff --git a/app/cmd/routes.go b/app/cmd/routes.goindex 14f74b558..c1435f4fc 100644--- a/app/cmd/routes.go+++ b/app/cmd/routes.go@@ -146,6 +146,8 @@ func routes(r *web.Engine) *web.Engine {ui.Post("/_api/admin/settings/privacy", handlers.UpdatePrivacy())ui.Post("/_api/admin/oauth", handlers.SaveOAuthConfig())ui.Post("/_api/admin/roles/:role/users", handlers.ChangeUserRole())+ ui.Put("/_api/admin/users/:userID/block", handlers.BlockUser())+ ui.Delete("/_api/admin/users/:userID/block", handlers.UnblockUser())}api := r.Group()diff --git a/app/handlers/user.go b/app/handlers/user.gonew file mode 100644index 000000000..abb7c5573--- /dev/null+++ b/app/handlers/user.go@@ -0,0 +1,39 @@+package handlers++import (+ "github.com/getfider/fider/app/pkg/web"+)++// BlockUser is used to block an existing user from using Fider+func BlockUser() web.HandlerFunc {+ return func(c web.Context) error {+ userID, err := c.ParamAsInt("userID")+ if err != nil {+ return c.NotFound()+ }++ err = c.Services().Users.Block(userID)+ if err != nil {+ return c.Failure(err)+ }++ return c.Ok(web.Map{})+ }+}++// UnblockUser is used to unblock an existing user so they can use Fider again+func UnblockUser() web.HandlerFunc {+ return func(c web.Context) error {+ userID, err := c.ParamAsInt("userID")+ if err != nil {+ return c.NotFound()+ }++ err = c.Services().Users.Unblock(userID)+ if err != nil {+ return c.Failure(err)+ }++ return c.Ok(web.Map{})+ }+}diff --git a/app/middlewares/user.go b/app/middlewares/user.goindex 320d67d90..98ab16424 100644--- a/app/middlewares/user.go+++ b/app/middlewares/user.go@@ -89,7 +89,7 @@ func User() web.MiddlewareFunc {if user != nil && c.Tenant() != nil && user.Tenant.ID == c.Tenant().ID {- if user.Status == models.UserBanned {+ if user.Status == models.UserBlocked {c.RemoveCookie(web.CookieAuthName)return c.Unauthorized()}diff --git a/app/middlewares/user_test.go b/app/middlewares/user_test.goindex d59d15f36..0bec648d2 100644--- a/app/middlewares/user_test.go+++ b/app/middlewares/user_test.go@@ -54,11 +54,11 @@ func TestUser_WithCookie(t *testing.T) {Expect(response.HeaderMap["Set-Cookie"]).HasLen(0)}-func TestUser_Banned(t *testing.T) {+func TestUser_Blocked(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()- mock.JonSnow.Status = models.UserBanned+ mock.JonSnow.Status = models.UserBlockedtoken, _ := jwt.Encode(jwt.FiderClaims{UserID: mock.JonSnow.ID,UserName: mock.JonSnow.Name,diff --git a/app/models/identity.go b/app/models/identity.goindex ef4dc2d76..30bf8cb99 100644--- a/app/models/identity.go+++ b/app/models/identity.go@@ -45,18 +45,44 @@ type User struct {Tenant *Tenant `json:"-"`Role Role `json:"role"`Providers []*UserProvider `json:"-"`- Status int `json:"-"`+ Status UserStatus `json:"status"`}+//UserStatus is the status of a user+type UserStatus int+var (//UserActive is the default status for users- UserActive = 1+ UserActive UserStatus = 1//UserDeleted is used for users that chose to delete their accounts- UserDeleted = 2- //UserBanned is used for users that have been banned by staff members- UserBanned = 3+ UserDeleted UserStatus = 2+ //UserBlocked is used for users that have been blocked by staff members+ UserBlocked UserStatus = 3)+var userStatusIDs = map[UserStatus]string{+ UserActive: "active",+ UserDeleted: "deleted",+ UserBlocked: "blocked",+}++var userStatusName = map[string]UserStatus{+ "active": UserActive,+ "deleted": UserDeleted,+ "blocked": UserBlocked,+}++// MarshalText returns the Text version of the user status+func (status UserStatus) MarshalText() ([]byte, error) {+ return []byte(userStatusIDs[status]), nil+}++// UnmarshalText parse string into a user status+func (status *UserStatus) UnmarshalText(text []byte) error {+ *status = userStatusName[string(text)]+ return nil+}+//Role is the role of a user inside a tenanttype Role int@@ -81,12 +107,12 @@ var roleNames = map[string]Role{"administrator": RoleAdministrator,}-// MarshalText returns the Text version of the post status+// MarshalText returns the Text version of the user rolefunc (role Role) MarshalText() ([]byte, error) {return []byte(roleIDs[role]), nil}-// UnmarshalText parse string into a post status+// UnmarshalText parse string into a user rolefunc (role *Role) UnmarshalText(text []byte) error {*role = roleNames[string(text)]return nildiff --git a/app/storage/inmemory/user.go b/app/storage/inmemory/user.goindex d060677b8..ed2715277 100644--- a/app/storage/inmemory/user.go+++ b/app/storage/inmemory/user.go@@ -176,3 +176,29 @@ func (s *UserStorage) GetByAPIKey(apiKey string) (*models.User, error) {}return nil, app.ErrNotFound}++// Block a given user from using Fider+func (s *UserStorage) Block(userID int) error {+ user, err := s.GetByID(userID)+ if err != nil {+ return err+ }++ if user.Status == models.UserActive {+ user.Status = models.UserBlocked+ }+ return nil+}++// Unblock a given user so that they can use Fider again+func (s *UserStorage) Unblock(userID int) error {+ user, err := s.GetByID(userID)+ if err != nil {+ return err+ }++ if user.Status == models.UserBlocked {+ user.Status = models.UserActive+ }+ return nil+}diff --git a/app/storage/postgres/user.go b/app/storage/postgres/user.goindex 7ba5c89e4..06f43ccd4 100644--- a/app/storage/postgres/user.go+++ b/app/storage/postgres/user.go@@ -40,7 +40,7 @@ func (u *dbUser) toModel() *models.User {Tenant: u.Tenant.toModel(),Role: models.Role(u.Role.Int64),Providers: make([]*models.UserProvider, len(u.Providers)),- Status: int(u.Status.Int64),+ Status: models.UserStatus(u.Status.Int64),}for i, p := range u.Providers {@@ -346,3 +346,25 @@ func (s *UserStorage) GetByAPIKey(apiKey string) (*models.User, error) {}return user, nil}++// Block a given user from using Fider+func (s *UserStorage) Block(userID int) error {+ if _, err := s.trx.Execute(+ "UPDATE users SET status = $3 WHERE id = $1 AND tenant_id = $2",+ userID, s.tenant.ID, models.UserBlocked,+ ); err != nil {+ return errors.Wrap(err, "failed to block user")+ }+ return nil+}++// Unblock a given user so that they can use Fider again+func (s *UserStorage) Unblock(userID int) error {+ if _, err := s.trx.Execute(+ "UPDATE users SET status = $3 WHERE id = $1 AND tenant_id = $2",+ userID, s.tenant.ID, models.UserActive,+ ); err != nil {+ return errors.Wrap(err, "failed to unblock user")+ }+ return nil+}diff --git a/app/storage/postgres/user_test.go b/app/storage/postgres/user_test.goindex a65a787c1..f3e8db47a 100644--- a/app/storage/postgres/user_test.go+++ b/app/storage/postgres/user_test.go@@ -355,3 +355,29 @@ func TestUserStorage_APIKey(t *testing.T) {Expect(user).IsNil()Expect(errors.Cause(err)).Equals(app.ErrNotFound)}++func TestUserStorage_BlockUser(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ users.SetCurrentTenant(demoTenant)+ userID := 1++ user, err := users.GetByID(userID)+ Expect(err).IsNil()+ Expect(user.Status).Equals(models.UserActive)++ err = users.Block(userID)+ Expect(err).IsNil()++ user, err = users.GetByID(userID)+ Expect(err).IsNil()+ Expect(user.Status).Equals(models.UserBlocked)++ err = users.Unblock(userID)+ Expect(err).IsNil()++ user, err = users.GetByID(userID)+ Expect(err).IsNil()+ Expect(user.Status).Equals(models.UserActive)+}diff --git a/app/storage/storage.go b/app/storage/storage.goindex d94f2a36a..4dca27533 100644--- a/app/storage/storage.go+++ b/app/storage/storage.go@@ -57,6 +57,8 @@ type User interface {HasSubscribedTo(postID int) (bool, error)GetByAPIKey(apiKey string) (*models.User, error)RegenerateAPIKey() (string, error)+ Block(userID int) error+ Unblock(userID int) error}// Tenant contains read and write operations for tenantsdiff --git a/public/assets/styles/variables.scss b/public/assets/styles/variables.scssindex 3852fe169..08d0df86a 100644--- a/public/assets/styles/variables.scss+++ b/public/assets/styles/variables.scss@@ -53,6 +53,11 @@ $xl-width: 1200px;@content;}}+ @else if $media == "<=md" {+ @media only screen and (max-width: #{$lg-width - 0.1px}) {+ @content;+ }+ }@else if $media == "md" {@media only screen and (min-width: #{$md-width}) and (max-width: #{$lg-width - 0.1px}) {@content;diff --git a/public/components/VoteCounter.spec.tsx b/public/components/VoteCounter.spec.tsxindex 7ac306227..168fec555 100644--- a/public/components/VoteCounter.spec.tsx+++ b/public/components/VoteCounter.spec.tsx@@ -1,6 +1,6 @@import React from "react";import { shallow } from "enzyme";-import { Post, UserRole, PostStatus } from "@fider/models";+import { Post, UserRole, PostStatus, UserStatus } from "@fider/models";import { VoteCounter } from "@fider/components";import { httpMock, fiderMock, rerender } from "@fider/services/testing";@@ -18,7 +18,8 @@ beforeEach(() => {user: {id: 5,name: "John",- role: UserRole.Collaborator+ role: UserRole.Collaborator,+ status: UserStatus.Active},hasVoted: false,response: null,diff --git a/public/components/common/DropDown.tsx b/public/components/common/DropDown.tsxindex 3382307a2..d20be6041 100644--- a/public/components/common/DropDown.tsx+++ b/public/components/common/DropDown.tsx@@ -13,7 +13,7 @@ export interface DropDownItem {export interface DropDownProps {className?: string;defaultValue?: any;- items: DropDownItem[];+ items: Array<DropDownItem | undefined | false>;placeholder?: string;searchable?: boolean;inline?: boolean;@@ -81,9 +81,9 @@ export class DropDown extends React.Component<DropDownProps, DropDownState> {);};- public findItem(value: any, items: DropDownItem[]): DropDownItem | undefined {+ public findItem(value: any, items: Array<DropDownItem | undefined | false>): DropDownItem | undefined {for (const item of items) {- if (item.value === value) {+ if (item && item.value === value) {return item;}}@@ -105,7 +105,11 @@ export class DropDown extends React.Component<DropDownProps, DropDownState> {}}- public renderItem = (item: DropDownItem) => {+ public renderItem = (item: DropDownItem | undefined | false) => {+ if (!item) {+ return;+ }+const { label, value } = item;const isSelected = this.props.highlightSelected && this.state.selected && value === this.state.selected.value;const className = classSet({diff --git a/public/models/identity.ts b/public/models/identity.tsindex c387f85c2..746cbd7da 100644--- a/public/models/identity.ts+++ b/public/models/identity.ts@@ -13,6 +13,13 @@ export interface User {id: number;name: string;role: UserRole;+ status: UserStatus;+}++export enum UserStatus {+ Active = "active",+ Deleted = "deleted",+ Blocked = "blocked"}export enum UserRole {@@ -30,6 +37,7 @@ export interface CurrentUser {name: string;email: string;role: UserRole;+ status: UserStatus;isAdministrator: boolean;isCollaborator: boolean;}diff --git a/public/pages/Administration/components/UserListItem.tsx b/public/pages/Administration/components/UserListItem.tsxdeleted file mode 100644index 6f0f79fb2..000000000--- a/public/pages/Administration/components/UserListItem.tsx+++ /dev/null@@ -1,51 +0,0 @@-import React from "react";-import { User, UserRole } from "@fider/models";-import { ListItem, Gravatar, UserName, Button } from "@fider/components";-import { actions } from "@fider/services";--interface UserListItemProps {- user: User;- role: UserRole;- removable: boolean;- addable: boolean;- onChange: () => void;-}--export class UserListItem extends React.Component<UserListItemProps, {}> {- private promote = async () => {- await this.changeRole(this.props.role);- };-- private demote = async () => {- await this.changeRole(UserRole.Visitor);- };-- private changeRole = async (role: UserRole) => {- const response = await actions.changeUserRole(this.props.user.id, role);- if (response.ok) {- this.props.user.role = role;- this.props.onChange();- }- };-- public render() {- return (- <ListItem>- <Gravatar user={this.props.user} />- <div className="content">- <UserName user={this.props.user} />- </div>- {this.props.removable && (- <Button size="tiny" color="danger" onClick={this.demote} className="right showover">- Remove- </Button>- )}- {this.props.addable && (- <Button size="tiny" color="positive" onClick={this.promote} className="right showover">- Add- </Button>- )}- </ListItem>- );- }-}diff --git a/public/pages/Administration/pages/ManageMembers.page.scss b/public/pages/Administration/pages/ManageMembers.page.scssindex c7bf12dcf..84738515b 100644--- a/public/pages/Administration/pages/ManageMembers.page.scss+++ b/public/pages/Administration/pages/ManageMembers.page.scss@@ -1,8 +1,57 @@+@import '~@fider/assets/styles/variables.scss';+#p-admin-members {+ @include media("<=md") {+ .col-left {+ .c-list-item:last-child {+ margin-bottom: 15px;+ }+ }+ .col-right {+ .c-list-item:first-child {+ padding-top: 15px;+ border-top: 1px solid $gray-lighter;+ }+ }+ }++ .l-legend {+ list-style-type: none;+ padding-left: 0;+ }+.c-list-item {- .content {+ .c-avatar {+ margin-right: 5px;+ }+ .l-user-details {display: inline-block;+ vertical-align: middle;+ span {+ display: block;+ }+ }+ .l-user-actions {+ display: inline-block;+ cursor: pointer;+ vertical-align: middle;margin-left: 5px;+ .c-dropdown-text {+ color: $gray-dark;+ }+ }+ .staff {+ font-size: $font-size-tiny;+ }+ .blocked {+ font-size: $font-size-tiny;+ color: $red;}- }+ }++ .l-show-more {+ cursor: pointer;+ font-weight: bold;+ padding-left: 5px;+ }}\ No newline at end of filediff --git a/public/pages/Administration/pages/ManageMembers.page.tsx b/public/pages/Administration/pages/ManageMembers.page.tsxindex d4818ca17..6d968c1bd 100644--- a/public/pages/Administration/pages/ManageMembers.page.tsx+++ b/public/pages/Administration/pages/ManageMembers.page.tsx@@ -1,27 +1,71 @@import "./ManageMembers.page.scss";import React from "react";-import { Segment, List, Input, Form } from "@fider/components/common";-import { User, UserRole } from "@fider/models";-import { Fider } from "@fider/services";-import { FaUsers } from "react-icons/fa";+import { Segment, List, Input, ListItem, Gravatar, UserName, DropDown, DropDownItem } from "@fider/components/common";+import { User, UserRole, UserStatus } from "@fider/models";import { AdminBasePage } from "../components/AdminBasePage";-import { UserListItem } from "../components/UserListItem";+import { FaUsers, FaEllipsisH, FaTimes, FaSearch } from "react-icons/fa";+import { actions, Fider } from "@fider/services";interface ManageMembersPageState {- administrators: User[];- collaborators: User[];- visitors: User[];- filteredNewAdministrators: User[];- filteredNewCollaborators: User[];- newAdministratorFilter: string;- newCollaboratorFilter: string;+ query: string;+ users: User[];+ visibleUsers: User[];}interface ManageMembersPageProps {users: User[];}+interface UserListItemProps {+ user: User;+ onAction: (actionName: string, user: User) => Promise<void>;+}++const UserListItem = (props: UserListItemProps) => {+ const admin = props.user.role === UserRole.Administrator && <span className="staff">administrator</span>;+ const collaborator = props.user.role === UserRole.Collaborator && <span className="staff">collaborator</span>;+ const blocked = props.user.status === UserStatus.Blocked && <span className="blocked">blocked</span>;+ const isVisitor = props.user.role === UserRole.Visitor;++ const renderEllipsis = () => {+ return <FaEllipsisH />;+ };++ const actionSelected = (item: DropDownItem) => {+ props.onAction(item.value, props.user);+ };++ return (+ <ListItem>+ <Gravatar user={props.user} />+ <div className="l-user-details">+ <UserName user={props.user} />+ <span>+ {admin} {collaborator} {blocked}+ </span>+ </div>+ {Fider.session.user.id !== props.user.id && Fider.session.user.isAdministrator && (+ <DropDown+ className="l-user-actions"+ inline={true}+ highlightSelected={false}+ items={[+ !blocked &&+ (!!collaborator || isVisitor) && { label: "Promote to Administrator", value: "to-administrator" },+ !blocked && (!!admin || isVisitor) && { label: "Promote to Collaborator", value: "to-collaborator" },+ !blocked && (!!collaborator || !!admin) && { label: "Demote to Visitor", value: "to-visitor" },+ isVisitor && !blocked && { label: "Block User", value: "block" },+ isVisitor && !!blocked && { label: "Unblock User", value: "unblock" }+ ]}+ renderText={renderEllipsis}+ onChange={actionSelected}+ />+ )}+ </ListItem>+ );+};+export class ManageMembersPage extends AdminBasePage<ManageMembersPageProps, ManageMembersPageState> {public id = "p-admin-members";public name = "members";@@ -31,134 +75,129 @@ export class ManageMembersPage extends AdminBasePage<ManageMembersPageProps, Manconstructor(props: ManageMembersPageProps) {super(props);- this.state = this.groupUsers();- }- private groupUsers(): ManageMembersPageState {- const usersByRole = this.props.users.reduce<{ [key: string]: User[] }>((groups, x) => {- groups[x.role] = [x].concat(groups[x.role] || []);- return groups;- }, {});-- return {- administrators: usersByRole[UserRole.Administrator] || [],- collaborators: usersByRole[UserRole.Collaborator] || [],- visitors: usersByRole[UserRole.Visitor] || [],- filteredNewAdministrators: [],- filteredNewCollaborators: [],- newAdministratorFilter: "",- newCollaboratorFilter: ""+ const users = this.props.users.sort(this.sortByStaff);+ this.state = {+ query: "",+ users,+ visibleUsers: users.slice(0, 10)};}- private onRoleChanged = () => {- this.setState(this.groupUsers());+ private showMore = (event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>): void => {+ event.preventDefault();+ this.setState({+ visibleUsers: this.state.users.slice(0, this.state.visibleUsers.length + 10)+ });};- private showUser(user: User, role: UserRole, addable: boolean, removable: boolean) {- if (user.id === Fider.session.user.id || Fider.session.user.role !== UserRole.Administrator) {- removable = false;- }+ private clearSearch = () => {+ this.handleSearchFilterChanged("");+ };- return (- <UserListItem- key={user.id}- role={role}- user={user}- addable={addable}- removable={removable}- onChange={this.onRoleChanged}- />- );- }+ private handleSearchFilterChanged = (query: string) => {+ const users = this.props.users+ .filter(x => x.name.toLowerCase().indexOf(query.toLowerCase()) >= 0)+ .sort(this.sortByStaff);+ this.setState({ query, users, visibleUsers: users.slice(0, 10) });+ };++ private handleAction = async (actionName: string, user: User) => {+ const changeRole = async (role: UserRole) => {+ const result = await actions.changeUserRole(user.id, role);+ if (result.ok) {+ user.role = role;+ }+ this.handleSearchFilterChanged(this.state.query);+ };++ const changeStatus = async (status: UserStatus) => {+ const action = status === UserStatus.Blocked ? actions.blockUser : actions.unblockUser;+ const result = await action(user.id);+ if (result.ok) {+ user.status = status;+ }+ this.forceUpdate();+ };- private filterVisitors(property: string, text: string) {- let filtered: User[] = [];- if (text) {- filtered = this.state.visitors.filter(x => x.name.toLowerCase().indexOf(text.toLowerCase()) >= 0);+ if (actionName === "to-collaborator") {+ await changeRole(UserRole.Collaborator);+ } else if (actionName === "to-visitor") {+ await changeRole(UserRole.Visitor);+ } else if (actionName === "to-administrator") {+ await changeRole(UserRole.Administrator);+ } else if (actionName === "block") {+ await changeStatus(UserStatus.Blocked);+ } else if (actionName === "unblock") {+ await changeStatus(UserStatus.Active);}+ };- if (property === "administrator") {- this.setState({- newAdministratorFilter: text,- filteredNewAdministrators: filtered- });- } else if (property === "collaborator") {- this.setState({- newCollaboratorFilter: text,- filteredNewCollaborators: filtered- });+ private sortByStaff = (left: User, right: User) => {+ if (right.role === left.role) {+ if (left.name < right.name) {+ return -1;+ } else if (left.name > right.name) {+ return 1;+ }+ return 0;}- }- private handleSearch = {- administrator: (query: string) => {- this.filterVisitors("administrator", query);- },- collaborator: (query: string) => {- this.filterVisitors("collaborator", query);+ if (right.role !== UserRole.Visitor) {+ return 1;}+ return -1;};public content() {return (- <div className="row">- <div className="col-lg-6">- <Segment>- <h4>Administrators</h4>- <p className="info">- Administrators have full access to edit and manage content, permissions and settings.- </p>- <List hover={true}>- {this.state.administrators.map(x => this.showUser(x, UserRole.Administrator, false, true))}- </List>- {Fider.session.user.isAdministrator && (- <Form size="mini">- <Input- label="Add new administrator"- field="new-administrator"- value={this.state.newAdministratorFilter}- onChange={this.handleSearch.administrator}- placeholder="Search users by name"- />- <List hover={true}>- {this.state.filteredNewAdministrators.map(x => this.showUser(x, UserRole.Administrator, true, false))}- </List>- {this.state.newAdministratorFilter && this.state.filteredNewAdministrators.length === 0 && (- <p className="info">No users to show.</p>- )}- </Form>- )}- </Segment>- </div>-- <div className="col-lg-6">- <Segment>- <h4>Collaborators</h4>- <p className="info">Collaborators can edit and manage content, but not permissions and settings.</p>- <List hover={true}>- {this.state.collaborators.map(x => this.showUser(x, UserRole.Collaborator, false, true))}- </List>- {Fider.session.user.isAdministrator && (- <Form size="mini">- <Input- label="Add new collaborator"- field="new-collaborator"- value={this.state.newCollaboratorFilter}- onChange={this.handleSearch.collaborator}- placeholder="Search users by name"- />- <List hover={true}>- {this.state.filteredNewCollaborators.map(x => this.showUser(x, UserRole.Collaborator, true, false))}- </List>- {this.state.newCollaboratorFilter && this.state.filteredNewCollaborators.length === 0 && (- <p className="info">No users to show.</p>- )}- </Form>- )}- </Segment>- </div>- </div>+ <>+ <Input+ field="query"+ icon={this.state.query ? FaTimes : FaSearch}+ onIconClick={this.state.query ? this.clearSearch : undefined}+ placeholder="Search for users by name..."+ value={this.state.query}+ onChange={this.handleSearchFilterChanged}+ />+ <Segment>+ {this.state.visibleUsers.length === 0 && <span>No users found.</span>}+ <List divided={true}>+ {this.state.visibleUsers.map(user => (+ <UserListItem key={user.id} user={user} onAction={this.handleAction} />+ ))}+ </List>+ </Segment>+ <p className="info">+ {!this.state.query && (+ <>+ Showing {this.state.visibleUsers.length} of {this.state.users.length} registered users+ </>+ )}+ {this.state.query && (+ <>+ Showing {this.state.visibleUsers.length} of {this.state.users.length} users matching '{this.state.query}'+ </>+ )}+ {this.state.visibleUsers.length < this.state.users.length && (+ <a className="l-show-more" onTouchEnd={this.showMore} onClick={this.showMore}>+ view more+ </a>+ )}+ </p>+ <ul className="l-legend info">+ <li>+ <strong>· Administrators</strong> have full access to edit and manage content, permissions and+ settings.+ </li>+ <li>+ <strong>· Collaborators</strong> can edit and manage content, but not permissions and settings.+ </li>+ <li>+ <strong>· Blocked</strong> users are unable to log into this site.+ </li>+ </ul>+ </>);}}diff --git a/public/pages/UI/UIToolkit.page.tsx b/public/pages/UI/UIToolkit.page.tsxindex 50804d911..fa18de74f 100644--- a/public/pages/UI/UIToolkit.page.tsx+++ b/public/pages/UI/UIToolkit.page.tsx@@ -1,5 +1,5 @@import React from "react";-import { PostStatus } from "@fider/models";+import { PostStatus, UserStatus } from "@fider/models";import {Heading,Button,@@ -30,13 +30,15 @@ import { FaSearch, FaRegLightbulb, FaCogs } from "react-icons/fa";const jonSnow: User = {id: 0,name: "Jon Snow",- role: UserRole.Administrator+ role: UserRole.Administrator,+ status: UserStatus.Active};const aryaStark: User = {id: 0,name: "Arya Snow",- role: UserRole.Visitor+ role: UserRole.Visitor,+ status: UserStatus.Active};const easyTag: Tag = { id: 2, slug: "easy", name: "easy", color: "FB3A62", isPublic: true };diff --git a/public/services/actions/tenant.ts b/public/services/actions/tenant.tsindex a795a8810..0d65adace 100644--- a/public/services/actions/tenant.ts+++ b/public/services/actions/tenant.ts@@ -74,6 +74,14 @@ export const changeUserRole = async (userID: number, role: UserRole): Promise<Re});};+export const blockUser = async (userID: number): Promise<Result> => {+ return await http.put(`/_api/admin/users/${userID}/block`);+};++export const unblockUser = async (userID: number): Promise<Result> => {+ return await http.delete(`/_api/admin/users/${userID}/block`);+};+export const getOAuthConfig = async (provider: string): Promise<Result<OAuthConfig>> => {return await http.get<OAuthConfig>(`/_api/admin/oauth/${provider}`);};