Skip to content

Commit dd6ee03

Browse files
committed
Issues-108
1 parent cfc4e34 commit dd6ee03

File tree

1 file changed

+7
-61
lines changed

1 file changed

+7
-61
lines changed

Topcoder/class.topcoder.plugin.php

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ public function setup() {
127127
], ['AuthenticationKey' => 'topcoder']);
128128
}
129129

130-
// $this->initDefaultVanillaRoles();
131-
// $this->initDefaultTopcoderRoles();
132-
133130
$this->initCache();
134131
}
135132

@@ -161,39 +158,6 @@ private function initCache() {
161158
}
162159
}
163160

164-
/**
165-
* Init all default Topcoder roles and set up permissions
166-
*/
167-
private function initDefaultTopcoderRoles() {
168-
$defaultTopcoderRoles = TopcoderPlugin::getAllTopcoderRoles();
169-
$roleNames = array_column($defaultTopcoderRoles, 'roleName');
170-
$this->checkTopcoderRoles($roleNames);
171-
}
172-
173-
/**
174-
* Init all default Vanilla roles and set up permissions
175-
*/
176-
private function initDefaultVanillaRoles() {
177-
$permissionModel = Gdn::permissionModel();
178-
179-
// Update Vanilla Guest role
180-
$permissions = $permissionModel->getGlobalPermissions(2); // Guest role
181-
unset($permissions['PermissionID']);
182-
foreach ($permissions as $key => $value) {
183-
$permissions[$key] = 0;
184-
}
185-
$permissions['Role'] = RoleModel::TYPE_GUEST;
186-
$permissionModel->save($permissions);
187-
188-
// Update Vanilla Member role
189-
$permissionModel->save( [
190-
'Role' => 'Member',
191-
'Garden.Uploads.Add' => 0
192-
]);
193-
194-
$permissionModel->clearPermissions();
195-
}
196-
197161
/**
198162
* The settings page for the topcoder plugin.
199163
*
@@ -513,7 +477,9 @@ public function gdn_auth_startAuthenticator_handler() {
513477

514478
if ($userID) {
515479
$this->syncTopcoderRoles($userID,$topcoderRoles);
480+
Gdn::authenticator()->setIdentity($userID, true);
516481
Gdn::session()->start($userID, true);
482+
Gdn::authenticator()->trigger(Gdn_Authenticator::AUTH_SUCCESS);
517483
$userModel->fireEvent('AfterSignIn');
518484
$session = Gdn::session();
519485
if (!$session->isValid()) {
@@ -724,7 +690,7 @@ public function base_guestSignIn_handler($sender, $args) {
724690
* @param $args
725691
*/
726692
public function base_badSignIn_handler($sender, $args) {
727-
$this->startSessionAsGuest($sender, $args);
693+
$this->startSessionAsGuest($sender, $args);
728694
self::log('base_badSignIn_handler', ['Session Permissions' => Gdn::session()->getPermissionsArray()]);
729695

730696
}
@@ -749,12 +715,9 @@ private function startSessionAsGuest($sender, $args) {
749715
self::log('Ending session', ['Error' => $e.getMessage]);
750716
}
751717

752-
// Start the 'session' as Guests
753-
if (!Gdn::session()->isValid()) {
754-
self::log('Starting a session as guest', []);
755-
Gdn::session()->start(false, false);
756-
}
757-
718+
Gdn::authenticator()->setIdentity(null, false);
719+
Gdn::authenticator()->trigger(Gdn_Authenticator::AUTH_DENIED);
720+
self::log('Guest settings', ['IsValidSession' => Gdn::session()->isValid(), 'Session Permissions' => Gdn::session()->getPermissionsArray()]);
758721
}
759722

760723
public function entryController_topcoder_create($sender, $action = '', $errorCode = '') {
@@ -867,7 +830,7 @@ function gdn_dispatcher_beforeControllerMethod_handler($sender, $args){
867830
$controllerArgs = json_decode(json_encode($args['Controller']->ReflectArgs), TRUE);
868831
$methodArgs = array_change_key_case($controllerArgs,CASE_LOWER);
869832
self::log('gdn_dispatcher_beforeControllerMethod_handler', ['controller' => $args['Controller']->ControllerName,
870-
'reflectArgs' => $args['Controller']->ReflectArgs, 'args' => $args['Controller']->Data['test']
833+
'reflectArgs' => $args['Controller']->ReflectArgs
871834
]);
872835

873836
$groupID = false;
@@ -1672,23 +1635,6 @@ public function userModel_loadPermissions_handler($sender, $args){
16721635
'loadPermissions' => $args['Permissions']]);
16731636
}
16741637

1675-
// TODO: Debugging search
1676-
public function searchModel_search_handler($sender, $args){
1677-
self::log('searchModel_search_handler', ['Search' => $args['Search']]);
1678-
}
1679-
1680-
// TODO: Debugging search
1681-
public function searchModel_beforeGetSearchQuery_handler($sender, $args){
1682-
self::log('searchModel_beforeGetSearchQuery_handler', ['Sql' => $args['Sql'],
1683-
'Parameters' => $args['Parameters']]);
1684-
}
1685-
1686-
// TODO: Debugging search
1687-
public function searchController_beforeSearchExcerpt_handler($sender, $args){
1688-
self::log('searchController_beforeSearchExcerpt_handler', ['Record' => $args['Record']
1689-
]);
1690-
}
1691-
16921638
public static function log($message, $data = []) {
16931639
// TODO: Debugging issues-108
16941640
//if (c('Vanilla.SSO.Debug') || c('Debug')) {

0 commit comments

Comments
 (0)