File tree 2 files changed +16
-4
lines changed 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ export default function Menu() {
108
108
] ;
109
109
}
110
110
// Team menu
111
- if ( team ) {
112
- const currentUserInTeam = teamMembers [ team . id ] ;
111
+ if ( team && teamMembers && teamMembers [ team . id ] ) {
112
+ const currentUserInTeam = teamMembers [ team . id ] . find ( m => m . userId === user ?. id ) ;
113
113
114
114
const teamSettingsList = [
115
115
{
@@ -126,7 +126,7 @@ export default function Menu() {
126
126
link : `/t/${ team . slug } /members`
127
127
}
128
128
] ;
129
- if ( currentUserInTeam && currentUserInTeam [ 0 ] . role === "owner" ) {
129
+ if ( currentUserInTeam ? .role === "owner" ) {
130
130
teamSettingsList . push ( {
131
131
title : 'Settings' ,
132
132
link : `/t/${ team . slug } /settings` ,
Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
import { useContext , useState } from "react" ;
8
- import { useLocation } from "react-router" ;
8
+ import { Redirect , useLocation } from "react-router" ;
9
9
import ConfirmationModal from "../components/ConfirmationModal" ;
10
10
import { PageWithSubMenu } from "../components/PageWithSubMenu" ;
11
11
import { getGitpodService , gitpodHostUrl } from "../service/service" ;
@@ -37,6 +37,18 @@ export default function TeamSettings() {
37
37
}
38
38
]
39
39
40
+ const userIsOwner = async ( ) => {
41
+ if ( ! team ) return ;
42
+
43
+ const members = await getGitpodService ( ) . server . getTeamMembers ( team . id ) ;
44
+ const currentUserInTeam = members . find ( member => member . userId === user ?. id ) ;
45
+ return currentUserInTeam ?. role === 'owner' ;
46
+ }
47
+
48
+ if ( ! userIsOwner ) {
49
+ return < Redirect to = "/" />
50
+ }
51
+
40
52
return < >
41
53
< PageWithSubMenu subMenu = { settingsMenu } title = 'General' subtitle = 'Manage general team settings.' >
42
54
< h3 > Delete Team</ h3 >
You can’t perform that action at this time.
0 commit comments