Skip to content

Commit dc64f42

Browse files
authored
Merge pull request #44 from topcoder-platform/issues-setup
Merging config.php
2 parents 46d6dce + 90d91be commit dc64f42

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

ReplyTo/class.replyto.plugin.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public function structure() {
3434
* @throws Gdn_UserException
3535
*/
3636
public function setup() {
37-
// Initial data hasn't been inserted
38-
if(!c('Garden.Installed')) {
39-
return;
40-
}
4137
$this->structure();
4238
}
4339

Topcoder/class.topcoder.plugin.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,38 @@ public function structure() {
9292
* @throws Gdn_UserException
9393
*/
9494
public function setup() {
95-
// Initial data hasn't been inserted
96-
if(!c('Garden.Installed')) {
97-
return;
98-
}
9995

10096
$this->structure();
10197

98+
$topcoderSSOAuth0Url=getenv('TOPCODER_PLUGIN_SSO_REFRESHTOKENURL');
99+
$signInUrl = getenv('TOPCODER_PLUGIN_SIGNIN_URL');
100+
$signOutUrl = getenv('TOPCODER_PLUGIN_SIGNOUT_URL');
101+
if($signInUrl === false) {
102+
$signInUrl =$topcoderSSOAuth0Url.'?retUrl='.urlencode('https://'.$_SERVER['SERVER_NAME'].'/');
103+
}
104+
if($signOutUrl === false) {
105+
$signOutUrl =$topcoderSSOAuth0Url.'?logout=true&retUrl='.urlencode('https://'.$_SERVER['SERVER_NAME'].'/');
106+
}
107+
108+
$registerUrl = getenv('TOPCODER_PLUGIN_AUTHENTICATIONPROVIDER_REGISTERURL');
109+
102110
$model = new Gdn_AuthenticationProviderModel();
103111
$provider = $model->getID('topcoder');
104112
if(!$provider) {
105113
$provider['AuthenticationKey'] = 'topcoder';
106114
$provider['AuthenticationSchemeAlias'] = 'topcoder';
107-
$provider['SignInUrl'] = c('Plugins.Topcoder.AuthenticationProvider.SignInUrl');
108-
$provider['SignOutUrl'] = c('Plugins.Topcoder.AuthenticationProvider.SignOutUrl');
109-
$provider['RegisterUrl'] = c('Plugins.Topcoder.AuthenticationProvider.RegisterUrl');
115+
$provider['SignInUrl'] = $signInUrl;
116+
$provider['SignOutUrl'] = $signOutUrl;
117+
$provider['RegisterUrl'] = $registerUrl;
110118
$provider['Active'] = 1;
111-
$provider['Default'] = 1;
112-
$provider['IsDefault'] = 1;
119+
$provider['IsDefault'] = 0;
113120
$model->save($provider);
114121
}else {
115-
$model->update(['SignInUrl' => c('Plugins.Topcoder.AuthenticationProvider.SignInUrl'),
116-
'SignOutUrl' => c('Plugins.Topcoder.AuthenticationProvider.SignOutUrl'),
117-
'RegisterUrl' => c('Plugins.Topcoder.AuthenticationProvider.RegisterUrl')
122+
$model->update(['SignInUrl' => $signInUrl,
123+
'SignOutUrl' => $signOutUrl,
124+
'RegisterUrl' => $registerUrl ,
125+
'Active' => 1,
126+
'IsDefault' => 1
118127
], ['AuthenticationKey' => 'topcoder']);
119128
}
120129

@@ -205,16 +214,16 @@ public function settingsController_topcoder_create($sender) {
205214
$cf->form()->validateRule('Plugins.Topcoder.ResourcesApiURI', 'ValidateRequired', t('You must provide Resources API URI.'));
206215
$cf->form()->validateRule('Plugins.Topcoder.MemberProfileURL', 'ValidateRequired', t('You must provide Member Profile URL.'));
207216
if($cf->form()->getFormValue('Plugins.Topcoder.UseTopcoderAuthToken') == 1) {
208-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.SignInUrl', 'ValidateRequired', t('You must provide SignIn URL.'));
209-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.SignOutUrl', 'ValidateRequired', t('You must provide SignOut URL.'));
210-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.RegisterUrl', 'ValidateRequired', t('You must provide Register URL.'));
217+
$cf->form()->validateRule('AuthenticationProvider.SignInUrl', 'ValidateRequired', t('You must provide SignIn URL.'));
218+
$cf->form()->validateRule('AuthenticationProvider.SignOutUrl', 'ValidateRequired', t('You must provide SignOut URL.'));
219+
$cf->form()->validateRule('AuthenticationProvider.RegisterUrl', 'ValidateRequired', t('You must provide Register URL.'));
211220
$cf->form()->validateRule('Plugins.Topcoder.SSO.RefreshTokenURL', 'ValidateRequired', t('You must provide Refresh Token URL.'));
212221
$cf->form()->validateRule('Plugins.Topcoder.SSO.CookieName', 'ValidateRequired', t('You must provide Cookie Name.'));
213222
$cf->form()->validateRule('Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim', 'ValidateRequired', t('You must provide Username Claim for HS256 JWT.'));
214223
$cf->form()->validateRule('Plugins.Topcoder.SSO.TopcoderRS256.UsernameClaim', 'ValidateRequired', t('You must provide Username Claim for RS256 JWT.'));
215-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.SignInUrl', 'ValidateUrl','You must provide valid SignIn URL.');
216-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.SignOutUrl', 'ValidateUrl','You must provide valid SignOut URL.');
217-
$cf->form()->validateRule('Plugins.Topcoder.AuthenticationProvider.RegisterUrl', 'ValidateUrl','You must provide valid Register URL.');
224+
$cf->form()->validateRule('AuthenticationProvider.SignInUrl', 'ValidateUrl','You must provide valid SignIn URL.');
225+
$cf->form()->validateRule('AuthenticationProvider.SignOutUrl', 'ValidateUrl','You must provide valid SignOut URL.');
226+
$cf->form()->validateRule('AuthenticationProvider.RegisterUrl', 'ValidateUrl','You must provide valid Register URL.');
218227
$cf->form()->validateRule('Plugins.Topcoder.SSO.RefreshTokenURL', 'ValidateUrl','You must provide valid Refresh Token URL.');
219228
}
220229
}
@@ -227,10 +236,10 @@ public function settingsController_topcoder_create($sender) {
227236
'Plugins.Topcoder.ResourcesApiURI' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Resources API URI'],
228237
'Plugins.Topcoder.MemberProfileURL' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Member Profile URL'],
229238
'Plugins.Topcoder.UseTopcoderAuthToken' => ['Control' => 'CheckBox', 'Default' => false, 'Description' => 'Use Topcoder access token to log in to Vanilla'],
230-
'Plugins.Topcoder.AuthenticationProvider.SignInUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder SignIn URL'],
231-
'Plugins.Topcoder.AuthenticationProvider.SignOutUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder SignOut URL'],
232-
'Plugins.Topcoder.AuthenticationProvider.RegisterUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Register URL'],
233-
'Plugins.Topcoder.AuthenticationProvider.IsDefault' => ['Control' => 'CheckBox', 'Default' => true, 'Description' => 'Use Topcoder Auth0 provider'],
239+
'AuthenticationProvider.SignInUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder SignIn URL'],
240+
'AuthenticationProvider.SignOutUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder SignOut URL'],
241+
'AuthenticationProvider.RegisterUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Register URL'],
242+
'AuthenticationProvider.IsDefault' => ['Control' => 'CheckBox', 'Default' => true, 'Description' => 'Use Topcoder Auth0 provider'],
234243
'Plugins.Topcoder.SSO.RefreshTokenURL' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Refresh Token URL for RS256 JWT'],
235244
'Plugins.Topcoder.SSO.CookieName' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Cookie Name'],
236245
'Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Username Claim for HS256 JWT'],

0 commit comments

Comments
 (0)