@@ -43,7 +43,6 @@ class PageController extends Controller
43
43
private IUserSession $ userSession ;
44
44
45
45
public function __construct (IRequest $ request ,
46
- $ UserId ,
47
46
IConfig $ c ,
48
47
IMailer $ mailer ,
49
48
IL10N $ l ,
@@ -53,7 +52,6 @@ public function __construct(IRequest $request,
53
52
LoggerInterface $ logger
54
53
) {
55
54
parent ::__construct (Application::APP_ID , $ request );
56
- $ this ->userId = $ UserId ;
57
55
$ this ->c = $ c ;
58
56
$ this ->mailer = $ mailer ;
59
57
$ this ->l = $ l ;
@@ -62,6 +60,7 @@ public function __construct(IRequest $request,
62
60
$ this ->bc = $ backendManager ->getConnector ();
63
61
$ this ->utils = $ utils ;
64
62
$ this ->logger = $ logger ;
63
+ $ this ->userId = $ this ->userSession ->getUser ()?->getUID();
65
64
}
66
65
67
66
/**
@@ -79,13 +78,14 @@ public function index(): TemplateResponse
79
78
$ t = new TemplateResponse ($ this ->appName , 'index ' );
80
79
81
80
$ disable = false ;
82
- if (empty ($ this ->userId )) {
81
+ if (! empty ($ this ->userId )) {
83
82
$ allowedGroups = $ this ->c ->getAppValue ($ this ->appName ,
84
83
BackendUtils::KEY_LIMIT_TO_GROUPS );
85
84
if ($ allowedGroups !== '' ) {
86
85
$ aga = json_decode ($ allowedGroups , true );
87
86
if ($ aga !== null ) {
88
- $ userGroups = \OC ::$ server ->get (IGroupManager::class)->getUserIdGroups ($ this ->userId );
87
+ $ user = $ this ->userSession ->getUser ();
88
+ $ userGroups = \OC ::$ server ->get (IGroupManager::class)->getUserGroups ($ user );
89
89
$ disable = true ;
90
90
foreach ($ aga as $ ag ) {
91
91
if (array_key_exists ($ ag , $ userGroups )) {
0 commit comments