mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
chore: rename status to profile
This commit is contained in:
parent
ff963e36d7
commit
6b0b53269b
@ -84,7 +84,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
|
|||||||
token := findAccessToken(c)
|
token := findAccessToken(c)
|
||||||
if token == "" {
|
if token == "" {
|
||||||
// When the request is not authenticated, we allow the user to access the shortcut endpoints for those public shortcuts.
|
// When the request is not authenticated, we allow the user to access the shortcut endpoints for those public shortcuts.
|
||||||
if util.HasPrefixes(path, "/api/v1/workspace/status", "/s/*") && method == http.MethodGet {
|
if util.HasPrefixes(path, "/api/v1/workspace/profile", "/s/*") && method == http.MethodGet {
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
return echo.NewHTTPError(http.StatusUnauthorized, "Missing access token")
|
return echo.NewHTTPError(http.StatusUnauthorized, "Missing access token")
|
||||||
|
@ -49,16 +49,17 @@ func (upsert WorkspaceSettingUpsert) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorkspaceStatus struct {
|
type WorkspaceProfile struct {
|
||||||
Profile *profile.Profile `json:"profile"`
|
Profile *profile.Profile `json:"profile"`
|
||||||
DisallowSignUp bool `json:"disallowSignUp"`
|
DisallowSignUp bool `json:"disallowSignUp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) registerWorkspaceRoutes(g *echo.Group) {
|
func (s *APIV1Service) registerWorkspaceRoutes(g *echo.Group) {
|
||||||
g.GET("/workspace/status", func(c echo.Context) error {
|
g.GET("/workspace/profile", func(c echo.Context) error {
|
||||||
ctx := c.Request().Context()
|
ctx := c.Request().Context()
|
||||||
workspaceStatus := WorkspaceStatus{
|
workspaceProfile := WorkspaceProfile{
|
||||||
Profile: s.Profile,
|
Profile: s.Profile,
|
||||||
|
DisallowSignUp: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
disallowSignUpSetting, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
disallowSignUpSetting, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
||||||
@ -68,10 +69,10 @@ func (s *APIV1Service) registerWorkspaceRoutes(g *echo.Group) {
|
|||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to get workspace setting")
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to get workspace setting")
|
||||||
}
|
}
|
||||||
if disallowSignUpSetting != nil {
|
if disallowSignUpSetting != nil {
|
||||||
workspaceStatus.DisallowSignUp = disallowSignUpSetting.Value == "true"
|
workspaceProfile.DisallowSignUp = disallowSignUpSetting.Value == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, workspaceStatus)
|
return c.JSON(http.StatusOK, workspaceProfile)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.POST("/workspace/setting", func(c echo.Context) error {
|
g.POST("/workspace/setting", func(c echo.Context) error {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { Checkbox } from "@mui/joy";
|
import { Checkbox } from "@mui/joy";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { getSystemStatus, upsertWorkspaceSetting } from "../../helpers/api";
|
import { getWorkspaceProfile, upsertWorkspaceSetting } from "../../helpers/api";
|
||||||
|
|
||||||
const WorkspaceSection: React.FC = () => {
|
const WorkspaceSection: React.FC = () => {
|
||||||
const [disallowSignUp, setDisallowSignUp] = useState<boolean>(false);
|
const [disallowSignUp, setDisallowSignUp] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getSystemStatus().then(({ data }) => {
|
getWorkspaceProfile().then(({ data }) => {
|
||||||
setDisallowSignUp(data.disallowSignUp);
|
setDisallowSignUp(data.disallowSignUp);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
export function getSystemStatus() {
|
export function getWorkspaceProfile() {
|
||||||
return axios.get<SystemStatus>("/api/v1/workspace/status");
|
return axios.get<WorkspaceProfile>("/api/v1/workspace/profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signin(email: string, password: string) {
|
export function signin(email: string, password: string) {
|
||||||
|
2
web/src/types/modules/system.d.ts
vendored
2
web/src/types/modules/system.d.ts
vendored
@ -3,7 +3,7 @@ interface Profile {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SystemStatus {
|
interface WorkspaceProfile {
|
||||||
profile: Profile;
|
profile: Profile;
|
||||||
disallowSignUp: boolean;
|
disallowSignUp: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user