Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Facebook and Google Login Integration & LiveSync Update #573

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"license": "CC-BY-NC-4.0",
"require": {
"facebook/xhp-lib": "2.x",
"facebook/graph-sdk": "5.x",
"google/apiclient": "^2.0"
},
"require-dev": {
Expand Down
63 changes: 61 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ CREATE TABLE `livesync` (
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `teams_oauth`
--

DROP TABLE IF EXISTS `teams_oauth`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `teams_oauth` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` text NOT NULL,
`team_id` int(11) NOT NULL,
`token` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `teams_data`
--
Expand Down Expand Up @@ -219,13 +235,18 @@ INSERT INTO `configuration` (field, value, description) VALUES("registration", "
INSERT INTO `configuration` (field, value, description) VALUES("registration_names", "0", "(Boolean) Registration will ask for names");
INSERT INTO `configuration` (field, value, description) VALUES("registration_type", "1", "(Integer) Type of registration: 1 - Open; 2 - Tokenized;");
INSERT INTO `configuration` (field, value, description) VALUES("registration_players", "3", "(Integer) Number of players per team");
INSERT INTO `configuration` (field, value, description) VALUES("registration_facebook", "0", "(Boolean) Allow Facebook Registration");
INSERT INTO `configuration` (field, value, description) VALUES("registration_google", "0", "(Boolean) Allow Google Registration");
INSERT INTO `configuration` (field, value, description) VALUES("registration_prefix", "Hacker", "(String) Automated Team Registation Name Prefix");
INSERT INTO `configuration` (field, value, description) VALUES("ldap", "0", "(Boolean) Ability to use LDAP to login");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_server", "ldap://localhost", "(String) LDAP Server");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_port", "389", "(Integer) LDAP Port");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_domain_suffix", "@localhost", "(String) LDAP Domain");
INSERT INTO `configuration` (field, value, description) VALUES("login", "1", "(Boolean) Ability to login");
INSERT INTO `configuration` (field, value, description) VALUES("login_select", "0", "(Boolean) Login selecting the team");
INSERT INTO `configuration` (field, value, description) VALUES("login_strongpasswords", "0", "(Boolean) Enforce using strong passwords");
INSERT INTO `configuration` (field, value, description) VALUES("login_facebook", "0", "(Boolean) Allow Facebook Login");
INSERT INTO `configuration` (field, value, description) VALUES("login_google", "0", "(Boolean) Allow Google Login");
INSERT INTO `configuration` (field, value, description) VALUES("password_type", "1", "(Integer) Type of passwords: See table password_types");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonus", "30", "(Integer) Default value for bonus in levels");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec", "10", "(Integer) Default bonus decrement in levels");
Expand Down
21 changes: 21 additions & 0 deletions database/test_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ CREATE TABLE `livesync` (
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `teams_oauth`
--

DROP TABLE IF EXISTS `teams_oauth`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `teams_oauth` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` text NOT NULL,
`team_id` int(11) NOT NULL,
`token` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `teams_data`
--
Expand Down Expand Up @@ -219,13 +235,18 @@ INSERT INTO `configuration` (field, value, description) VALUES("registration", "
INSERT INTO `configuration` (field, value, description) VALUES("registration_names", "0", "(Boolean) Registration will ask for names");
INSERT INTO `configuration` (field, value, description) VALUES("registration_type", "1", "(Integer) Type of registration: 1 - Open; 2 - Tokenized;");
INSERT INTO `configuration` (field, value, description) VALUES("registration_players", "3", "(Integer) Number of players per team");
INSERT INTO `configuration` (field, value, description) VALUES("registration_facebook", "0", "(Boolean) Allow Facebook Registration");
INSERT INTO `configuration` (field, value, description) VALUES("registration_google", "0", "(Boolean) Allow Google Registration");
INSERT INTO `configuration` (field, value, description) VALUES("registration_prefix", "Hacker", "(String) Automated Team Registation Name Prefix");
INSERT INTO `configuration` (field, value, description) VALUES("ldap", "0", "(Boolean) Ability to use LDAP to login");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_server", "ldap://localhost", "(String) LDAP Server");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_port", "389", "(Integer) LDAP Port");
INSERT INTO `configuration` (field, value, description) VALUES("ldap_domain_suffix", "@localhost", "(String) LDAP Domain");
INSERT INTO `configuration` (field, value, description) VALUES("login", "1", "(Boolean) Ability to login");
INSERT INTO `configuration` (field, value, description) VALUES("login_select", "0", "(Boolean) Login selecting the team");
INSERT INTO `configuration` (field, value, description) VALUES("login_strongpasswords", "0", "(Boolean) Enforce using strong passwords");
INSERT INTO `configuration` (field, value, description) VALUES("login_facebook", "0", "(Boolean) Allow Facebook Login");
INSERT INTO `configuration` (field, value, description) VALUES("login_google", "0", "(Boolean) Allow Google Login");
INSERT INTO `configuration` (field, value, description) VALUES("password_type", "1", "(Integer) Type of passwords: See table password_types");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonus", "30", "(Integer) Default value for bonus in levels");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec", "10", "(Integer) Default bonus decrement in levels");
Expand Down
2 changes: 2 additions & 0 deletions extra/settings.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ DB_PASSWORD = 'MYPWD'
MC_HOST = 'MCHOST'
MC_PORT = '11211'

FACEBOOK_OAUTH_APP_ID = ''
FACEBOOK_OAUTH_APP_SECRET = ''
GOOGLE_OAUTH_FILE = ''
151 changes: 141 additions & 10 deletions src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AdminController extends Controller {
<<__Override>>
protected function getTitle(): string {
$custom_org = \HH\Asio\join(Configuration::gen('custom_org'));
return tr($custom_org->getValue()). ' '. tr('CTF'). ' | '. tr('Admin');
return tr($custom_org->getValue()).' '.tr('CTF').' | '.tr('Admin');
}

<<__Override>>
Expand Down Expand Up @@ -157,8 +157,8 @@ class="fb--conf--registration_type"
$select = <select name="fb--conf--password_type"></select>;
foreach ($types as $type) {
$select->appendChild(
<option
class="fb--conf--password_type"
<option
class="fb--conf--password_type"
value={strval($type->getField())}
selected={($type->getField() === $config->getField())}>
{$type->getDescription()}
Expand Down Expand Up @@ -298,7 +298,12 @@ class="fb-cta cta--yellow"
'login' => Configuration::gen('login'),
'login_select' => Configuration::gen('login_select'),
'login_strongpasswords' => Configuration::gen('login_strongpasswords'),
'login_facebook' => Configuration::gen('login_facebook'),
'login_google' => Configuration::gen('login_google'),
'registration_names' => Configuration::gen('registration_names'),
'registration_facebook' => Configuration::gen('registration_facebook'),
'registration_google' => Configuration::gen('registration_google'),
'registration_prefix' => Configuration::gen('registration_prefix'),
'ldap' => Configuration::gen('ldap'),
'ldap_server' => Configuration::gen('ldap_server'),
'ldap_port' => Configuration::gen('ldap_port'),
Expand Down Expand Up @@ -330,7 +335,13 @@ class="fb-cta cta--yellow"
$login = $results['login'];
$login_select = $results['login_select'];
$login_strongpasswords = $results['login_strongpasswords'];
$login_facebook = $results['login_facebook'];
$login_google = $results['login_google'];
$registration_names = $results['registration_names'];
$registration_facebook = $results['registration_facebook'];
$registration_google = $results['registration_google'];
$registration_prefix = $results['registration_prefix'];
$login_google = $results['login_google'];
$ldap = $results['ldap'];
$ldap_server = $results['ldap_server'];
$ldap_port = $results['ldap_port'];
Expand All @@ -352,13 +363,20 @@ class="fb-cta cta--yellow"
$custom_org = $results['custom_org'];
$custom_byline = $results['custom_byline'];
$custom_logo_image = $results['custom_logo_image'];

$registration_on = $registration->getValue() === '1';
$registration_off = $registration->getValue() === '0';
$login_on = $login->getValue() === '1';
$login_off = $login->getValue() === '0';
$login_select_on = $login_select->getValue() === '1';
$login_select_off = $login_select->getValue() === '0';
$login_facebook_on = $login_facebook->getValue() === '1';
$login_facebook_off = $login_facebook->getValue() === '0';
$login_google_on = $login_google->getValue() === '1';
$login_google_off = $login_google->getValue() === '0';
$registration_facebook_on = $registration_facebook->getValue() === '1';
$registration_facebook_off = $registration_facebook->getValue() === '0';
$registration_google_on = $registration_google->getValue() === '1';
$registration_google_off = $registration_google->getValue() === '0';
$ldap_on = $ldap->getValue() === '1';
$ldap_off = $ldap->getValue() === '0';
$strong_passwords_on = $login_strongpasswords->getValue() === '1';
Expand Down Expand Up @@ -476,15 +494,15 @@ class="fb-cta cta--yellow"
$custom_logo_xhp =
<div class="form-el el--block-label el--full-text">
<label for="">{tr('Logo')}</label>
<img
id="custom-logo-image"
class="icon--badge"
<img
id="custom-logo-image"
class="icon--badge"
src={$custom_logo_image->getValue()}
/>
<br/>
<h6>
<br />
<h6>
<a class="icon-text" href="#" id="custom-logo-link">
{tr('Change')}
{tr('Change')}
</a>
</h6>
<input
Expand Down Expand Up @@ -655,6 +673,119 @@ class="icon--badge"
</div>
</div>
</section>
<section class="admin-box">
<header class="admin-box-header">
<h3>{tr('Integration')}</h3>
</header>
<div class="fb-column-container">
<div class="col col-pad col-1-4">
<div class="form-el el--block-label">
<label>{tr('Facebook Login')}</label>
<div class="admin-section-toggle radio-inline">
<input
type="radio"
name="fb--conf--login_facebook"
id="fb--conf--login_facebook--on"
checked={$login_facebook_on}
/>
<label for="fb--conf--login_facebook--on">
{tr('On')}
</label>
<input
type="radio"
name="fb--conf--login_facebook"
id="fb--conf--login_facebook--off"
checked={$login_facebook_off}
/>
<label for="fb--conf--login_facebook--off">
{tr('Off')}
</label>
</div>
</div>
<div class="form-el el--block-label">
<label>{tr('Facebook Registration')}</label>
<div class="admin-section-toggle radio-inline">
<input
type="radio"
name="fb--conf--registration_facebook"
id="fb--conf--registration_facebook--on"
checked={$registration_facebook_on}
/>
<label for="fb--conf--registration_facebook--on">
{tr('On')}
</label>
<input
type="radio"
name="fb--conf--registration_facebook"
id="fb--conf--registration_facebook--off"
checked={$registration_facebook_off}
/>
<label for="fb--conf--registration_facebook--off">
{tr('Off')}
</label>
</div>
</div>
</div>
<div class="col col-pad col-2-4">
<div class="form-el el--block-label">
<label>{tr('Google Login')}</label>
<div class="admin-section-toggle radio-inline">
<input
type="radio"
name="fb--conf--login_google"
id="fb--conf--login_google--on"
checked={$login_google_on}
/>
<label for="fb--conf--login_google--on">
{tr('On')}
</label>
<input
type="radio"
name="fb--conf--login_google"
id="fb--conf--login_google--off"
checked={$login_google_off}
/>
<label for="fb--conf--login_google--off">
{tr('Off')}
</label>
</div>
</div>
<div class="form-el el--block-label">
<label>{tr('Google Registration')}</label>
<div class="admin-section-toggle radio-inline">
<input
type="radio"
name="fb--conf--registration_google"
id="fb--conf--registration_google--on"
checked={$registration_google_on}
/>
<label for="fb--conf--registration_google--on">
{tr('On')}
</label>
<input
type="radio"
name="fb--conf--registration_google"
id="fb--conf--registration_google--off"
checked={$registration_google_off}
/>
<label for="fb--conf--registration_google--off">
{tr('Off')}
</label>
</div>
</div>
</div>
<div class="col col-pad col-3-4">
<div class="form-el el--block-label el--full-text">
<label>{tr('Automatic Team Name Prefix')}</label>
<input
type="text"
value={$registration_prefix->getValue()}
name="fb--conf--registration_prefix"
/>
</div>
</div>
</div>
</section>
<section class="admin-box">
<header class="admin-box-header">
<h3>{tr('Active Directory / LDAP')}</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/GameboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class GameboardController extends Controller {
<<__Override>>
protected function getTitle(): string {
$custom_org = \HH\Asio\join(Configuration::gen('custom_org'));
return tr($custom_org->getValue()). ' '. tr('CTF').' | '.tr('Gameboard');
return tr($custom_org->getValue()).' '.tr('CTF').' | '.tr('Gameboard');
}

<<__Override>>
Expand Down
Loading