2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11
11
12
12
from typing import Optional
13
13
14
- from flask import Blueprint , current_app , escape
14
+ from flask import Blueprint , current_app , escape , session
15
15
from landoui .forms import (
16
16
ReasonCategory ,
17
17
TreeCategory ,
@@ -32,6 +32,25 @@ def is_user_authenticated() -> bool:
32
32
return helpers .is_user_authenticated ()
33
33
34
34
35
+ TREESTATUS_USER_GROUPS = {
36
+ "mozilliansorg_treestatus_admins" ,
37
+ "mozilliansorg_treestatus_users" ,
38
+ }
39
+
40
+
41
+ @template_helpers .app_template_global ()
42
+ def is_treestatus_user () -> bool :
43
+ if not is_user_authenticated ():
44
+ return False
45
+
46
+ try :
47
+ groups = session ["userinfo" ]["https://sso.mozilla.com/claim/groups" ]
48
+ except KeyError :
49
+ return False
50
+
51
+ return not TREESTATUS_USER_GROUPS .isdisjoint (groups )
52
+
53
+
35
54
@template_helpers .app_template_global ()
36
55
def user_has_phabricator_token () -> bool :
37
56
return helpers .get_phabricator_api_token () is not None
Original file line number Diff line number Diff line change 12
12
< h1 > Treestatus</ h1 >
13
13
< p > Current status of Mozilla's version-control repositories.</ p >
14
14
15
+ {% if is_treestatus_user() %}
15
16
{% include "treestatus/recent_changes.html" %}
17
+ {% endif %}
16
18
17
19
< h1 > Trees</ h1 >
18
20
{#
@@ -22,7 +24,7 @@ <h1>Trees</h1>
22
24
< form method ="post ">
23
25
{{ treestatus_update_trees_form.csrf_token }}
24
26
25
- {% if is_user_authenticated () %}
27
+ {% if is_treestatus_user () %}
26
28
< div class ="block ">
27
29
< a href ="{{ url_for( "treestatus.new_tree ") }}">
28
30
< button class ="button " title ="New Tree " type ="button "> New Tree</ button >
@@ -47,7 +49,7 @@ <h4 class="subtitle is-4 tree-category-header">{{ ns.current_category | tree_cat
47
49
48
50
< div class ="select-trees-box box ">
49
51
< div class ="columns ">
50
- {% if is_user_authenticated () %}
52
+ {% if is_treestatus_user () %}
51
53
< div class ="column is-1 ">
52
54
< input class ="tree-select-checkbox " type ="checkbox " name ="{{ tree_option.id }} " value ="{{ tree_option.data }} ">
53
55
</ div >
0 commit comments