mc-cms-namelessmc/modules/Core/classes/Integrations/MinecraftIntegration.php

254 lines
8.6 KiB
PHP
Raw Permalink Normal View History

User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
<?php
/**
* MinecraftIntegration class
*
* @package Modules\Core\Integrations
* @author Partydragen
* @version 2.1.0
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
* @license MIT
*/
class MinecraftIntegration extends IntegrationBase {
protected Language $_language;
private string $_uuid;
public function __construct(Language $language) {
$this->_name = 'Minecraft';
$this->_icon = 'fas fa-cubes';
$this->_language = $language;
$this->_settings = ROOT_PATH . '/modules/Core/includes/admin_integrations/minecraft.php';
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
parent::__construct();
}
2022-07-17 17:41:41 +02:00
private function flashVerifyCommand(string $verification_code): void {
$verification_command = Output::getClean(Settings::get('minecraft_verify_command', '/verify'));
$message = $this->_language->get('user', 'validate_account_command', ['command' => $verification_command . ' ' . $verification_code]);
Session::flash('connections_success', $message);
}
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
public function onLinkRequest(User $user) {
$username = $user->data()->username;
// Validate username
if (!$this->validateUsername($username)) {
return;
}
$result = $this->getUuidByUsername($username);
if (count($this->getErrors())) {
return;
}
$this->_uuid = $result['uuid'];
// Validate identifier
if (!$this->validateIdentifier($this->_uuid)) {
return;
}
2022-06-01 22:15:07 +02:00
$code = SecureRandom::alphanumeric();
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
$integrationUser = new IntegrationUser($this);
$integrationUser->linkIntegration($user, $this->_uuid, $username, false, $code);
$this->flashVerifyCommand($code);
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
}
public function onVerifyRequest(User $user) {
$integrationUser = new IntegrationUser($this, $user->data()->id, 'user_id');
$code = $integrationUser->data()->code;
if ($code === null) {
$code = SecureRandom::alphanumeric();
$integrationUser->update([
2023-01-26 14:08:11 -08:00
'code' => $code
]);
}
$this->flashVerifyCommand($code);
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
}
public function onUnlinkRequest(User $user) {
$integrationUser = new IntegrationUser($this, $user->data()->id, 'user_id');
$integrationUser->unlinkIntegration();
Use i18n for translations (#2658) * Dependency updates * Start i18n conversion * Switch to ellipsis character * Add Dutch language json * Remove Dutch PHP language files + fix variables * Further variable fixes * WIP i18n Language class conversion * Convert Cookie Consent module to new language format * Further progress including timeago translations * Misc * Replace {x} * Replace more {x} usage * {{time}} this took way too long * replace last {x} * Remove comments So searching for {x} produces relevant results * forgot to save * move to onPageLoad * Accept both string and int * types in doc * Remove unused (broken?) function * Don't convert to string first * Last arg doesn't seem to be used anywhere * Time `{x}` replacements * Email `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * remove comments (makes searching for "{x}" nicer) * misc `{x}` replacements * JS `{x}` replacements * Cleanup language initialization * Change language constant + add pluralForm support * Misc language update things * Add script to find unused terms * Check all quote types * Remove most english translations from non-english languages * Also match with more args * Missed some apparently * Missed some (more) apparently * Misc work * Add script to convert *all* language files to json * Fix language codes * Remove a lot of unused terms * Remove a lot more unused terms * Convert everything to JSON, delete old files, get installer working with new system * Fix general configuration language dropdown + email messages * Fix page load time, fix language term `set` method * Fix discord integration command * Misc * Misc * Uncomment RTL definition * Misc * Convert links * Convert links * Convert links * Convert links * Misc work (bolding, fixes, etc) * Style fix * Fix variable * Fix #2668 * Fix old page load timers * Fix installer group sync injector error * Convert integration language terms * Fix more integration language things * Re-add upgrade script language things * Resolve PR comments * Remove unnecessary date() * Resolve some PR issues * Fix endpoint * Style * Fix Semantic -> Fomantic * Fix Semantic -> Fomantic * Return locale short code, not language id/name Only the short code is interesting to the API, return short code in user info endpoint just like in the website info endpoint. Also renamed to locale because it's language + region * Revert "warn people to not translate old language files" This reverts commit 690b77afff5ff7cc2f931d3b49feaa9a9072002b. * Fix query when there are no filters * Update 200-pr12.php * Update footer.php * insert time into string using placeholder * Fix getDisplayname case * Clean username * PR suggestions * Include newly created language in converted languages (migration) * PR suggestions * PR suggestions * Update init.php * Fix default language Co-authored-by: samerton <samerton@users.noreply.github.com> Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl> Co-authored-by: Partydragen <adrian_kili@outlook.com>
2022-04-23 06:27:10 -07:00
Session::flash('connections_success', $this->_language->get('user', 'integration_unlinked', ['integration' => Output::getClean($this->_name)]));
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
}
public function onSuccessfulVerification(IntegrationUser $integrationUser) {
// Nothing to do here
}
public function validateUsername(string $username, int $integration_user_id = 0): bool {
$validation = Validate::check(['username' => $username], [
'username' => [
Validate::REQUIRED => true,
Validate::MIN => 3,
Validate::MAX => 20
]
])->messages([
'username' => [
Use i18n for translations (#2658) * Dependency updates * Start i18n conversion * Switch to ellipsis character * Add Dutch language json * Remove Dutch PHP language files + fix variables * Further variable fixes * WIP i18n Language class conversion * Convert Cookie Consent module to new language format * Further progress including timeago translations * Misc * Replace {x} * Replace more {x} usage * {{time}} this took way too long * replace last {x} * Remove comments So searching for {x} produces relevant results * forgot to save * move to onPageLoad * Accept both string and int * types in doc * Remove unused (broken?) function * Don't convert to string first * Last arg doesn't seem to be used anywhere * Time `{x}` replacements * Email `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * remove comments (makes searching for "{x}" nicer) * misc `{x}` replacements * JS `{x}` replacements * Cleanup language initialization * Change language constant + add pluralForm support * Misc language update things * Add script to find unused terms * Check all quote types * Remove most english translations from non-english languages * Also match with more args * Missed some apparently * Missed some (more) apparently * Misc work * Add script to convert *all* language files to json * Fix language codes * Remove a lot of unused terms * Remove a lot more unused terms * Convert everything to JSON, delete old files, get installer working with new system * Fix general configuration language dropdown + email messages * Fix page load time, fix language term `set` method * Fix discord integration command * Misc * Misc * Uncomment RTL definition * Misc * Convert links * Convert links * Convert links * Convert links * Misc work (bolding, fixes, etc) * Style fix * Fix variable * Fix #2668 * Fix old page load timers * Fix installer group sync injector error * Convert integration language terms * Fix more integration language things * Re-add upgrade script language things * Resolve PR comments * Remove unnecessary date() * Resolve some PR issues * Fix endpoint * Style * Fix Semantic -> Fomantic * Fix Semantic -> Fomantic * Return locale short code, not language id/name Only the short code is interesting to the API, return short code in user info endpoint just like in the website info endpoint. Also renamed to locale because it's language + region * Revert "warn people to not translate old language files" This reverts commit 690b77afff5ff7cc2f931d3b49feaa9a9072002b. * Fix query when there are no filters * Update 200-pr12.php * Update footer.php * insert time into string using placeholder * Fix getDisplayname case * Clean username * PR suggestions * Include newly created language in converted languages (migration) * PR suggestions * PR suggestions * Update init.php * Fix default language Co-authored-by: samerton <samerton@users.noreply.github.com> Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl> Co-authored-by: Partydragen <adrian_kili@outlook.com>
2022-04-23 06:27:10 -07:00
Validate::REQUIRED => $this->_language->get('admin', 'integration_username_required', ['integration' => $this->getName()]),
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
Validate::MIN => $this->_language->get('user', 'mcname_minimum_3'),
Validate::MAX => $this->_language->get('user', 'mcname_maximum_20')
]
]);
if (count($validation->errors())) {
// Validation errors
foreach ($validation->errors() as $error) {
$this->addError($error);
}
} else {
// Ensure identifier doesn't already exist
2022-05-01 23:16:22 -07:00
$exists = DB::getInstance()->query("SELECT * FROM nl2_users_integrations WHERE integration_id = ? AND username = ? AND id <> ?", [$this->data()->id, $username, $integration_user_id]);
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
if ($exists->count()) {
Use i18n for translations (#2658) * Dependency updates * Start i18n conversion * Switch to ellipsis character * Add Dutch language json * Remove Dutch PHP language files + fix variables * Further variable fixes * WIP i18n Language class conversion * Convert Cookie Consent module to new language format * Further progress including timeago translations * Misc * Replace {x} * Replace more {x} usage * {{time}} this took way too long * replace last {x} * Remove comments So searching for {x} produces relevant results * forgot to save * move to onPageLoad * Accept both string and int * types in doc * Remove unused (broken?) function * Don't convert to string first * Last arg doesn't seem to be used anywhere * Time `{x}` replacements * Email `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * remove comments (makes searching for "{x}" nicer) * misc `{x}` replacements * JS `{x}` replacements * Cleanup language initialization * Change language constant + add pluralForm support * Misc language update things * Add script to find unused terms * Check all quote types * Remove most english translations from non-english languages * Also match with more args * Missed some apparently * Missed some (more) apparently * Misc work * Add script to convert *all* language files to json * Fix language codes * Remove a lot of unused terms * Remove a lot more unused terms * Convert everything to JSON, delete old files, get installer working with new system * Fix general configuration language dropdown + email messages * Fix page load time, fix language term `set` method * Fix discord integration command * Misc * Misc * Uncomment RTL definition * Misc * Convert links * Convert links * Convert links * Convert links * Misc work (bolding, fixes, etc) * Style fix * Fix variable * Fix #2668 * Fix old page load timers * Fix installer group sync injector error * Convert integration language terms * Fix more integration language things * Re-add upgrade script language things * Resolve PR comments * Remove unnecessary date() * Resolve some PR issues * Fix endpoint * Style * Fix Semantic -> Fomantic * Fix Semantic -> Fomantic * Return locale short code, not language id/name Only the short code is interesting to the API, return short code in user info endpoint just like in the website info endpoint. Also renamed to locale because it's language + region * Revert "warn people to not translate old language files" This reverts commit 690b77afff5ff7cc2f931d3b49feaa9a9072002b. * Fix query when there are no filters * Update 200-pr12.php * Update footer.php * insert time into string using placeholder * Fix getDisplayname case * Clean username * PR suggestions * Include newly created language in converted languages (migration) * PR suggestions * PR suggestions * Update init.php * Fix default language Co-authored-by: samerton <samerton@users.noreply.github.com> Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl> Co-authored-by: Partydragen <adrian_kili@outlook.com>
2022-04-23 06:27:10 -07:00
$this->addError($this->_language->get('user', 'integration_username_already_linked', ['integration' => $this->getName()]));
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
return false;
}
}
return $validation->passed();
}
public function validateIdentifier(string $identifier, int $integration_user_id = 0): bool {
$validation = Validate::check(['identifier' => $identifier], [
'identifier' => [
Validate::REQUIRED => true,
Validate::MIN => 32,
Validate::MAX => 32
]
])->messages([
'identifier' => [
Use i18n for translations (#2658) * Dependency updates * Start i18n conversion * Switch to ellipsis character * Add Dutch language json * Remove Dutch PHP language files + fix variables * Further variable fixes * WIP i18n Language class conversion * Convert Cookie Consent module to new language format * Further progress including timeago translations * Misc * Replace {x} * Replace more {x} usage * {{time}} this took way too long * replace last {x} * Remove comments So searching for {x} produces relevant results * forgot to save * move to onPageLoad * Accept both string and int * types in doc * Remove unused (broken?) function * Don't convert to string first * Last arg doesn't seem to be used anywhere * Time `{x}` replacements * Email `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * remove comments (makes searching for "{x}" nicer) * misc `{x}` replacements * JS `{x}` replacements * Cleanup language initialization * Change language constant + add pluralForm support * Misc language update things * Add script to find unused terms * Check all quote types * Remove most english translations from non-english languages * Also match with more args * Missed some apparently * Missed some (more) apparently * Misc work * Add script to convert *all* language files to json * Fix language codes * Remove a lot of unused terms * Remove a lot more unused terms * Convert everything to JSON, delete old files, get installer working with new system * Fix general configuration language dropdown + email messages * Fix page load time, fix language term `set` method * Fix discord integration command * Misc * Misc * Uncomment RTL definition * Misc * Convert links * Convert links * Convert links * Convert links * Misc work (bolding, fixes, etc) * Style fix * Fix variable * Fix #2668 * Fix old page load timers * Fix installer group sync injector error * Convert integration language terms * Fix more integration language things * Re-add upgrade script language things * Resolve PR comments * Remove unnecessary date() * Resolve some PR issues * Fix endpoint * Style * Fix Semantic -> Fomantic * Fix Semantic -> Fomantic * Return locale short code, not language id/name Only the short code is interesting to the API, return short code in user info endpoint just like in the website info endpoint. Also renamed to locale because it's language + region * Revert "warn people to not translate old language files" This reverts commit 690b77afff5ff7cc2f931d3b49feaa9a9072002b. * Fix query when there are no filters * Update 200-pr12.php * Update footer.php * insert time into string using placeholder * Fix getDisplayname case * Clean username * PR suggestions * Include newly created language in converted languages (migration) * PR suggestions * PR suggestions * Update init.php * Fix default language Co-authored-by: samerton <samerton@users.noreply.github.com> Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl> Co-authored-by: Partydragen <adrian_kili@outlook.com>
2022-04-23 06:27:10 -07:00
Validate::REQUIRED => $this->_language->get('admin', 'integration_identifier_required', ['integration' => $this->getName()]),
Validate::MIN => $this->_language->get('admin', 'integration_identifier_invalid', ['integration' => $this->getName()]),
Validate::MAX => $this->_language->get('admin', 'integration_identifier_invalid', ['integration' => $this->getName()]),
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
]
]);
if (count($validation->errors())) {
// Validation errors
foreach ($validation->errors() as $error) {
$this->addError($error);
}
} else {
// Ensure identifier doesn't already exist
2022-05-01 23:16:22 -07:00
$exists = DB::getInstance()->query("SELECT * FROM nl2_users_integrations WHERE integration_id = ? AND identifier = ? AND id <> ?", [$this->data()->id, $identifier, $integration_user_id]);
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
if ($exists->count()) {
Use i18n for translations (#2658) * Dependency updates * Start i18n conversion * Switch to ellipsis character * Add Dutch language json * Remove Dutch PHP language files + fix variables * Further variable fixes * WIP i18n Language class conversion * Convert Cookie Consent module to new language format * Further progress including timeago translations * Misc * Replace {x} * Replace more {x} usage * {{time}} this took way too long * replace last {x} * Remove comments So searching for {x} produces relevant results * forgot to save * move to onPageLoad * Accept both string and int * types in doc * Remove unused (broken?) function * Don't convert to string first * Last arg doesn't seem to be used anywhere * Time `{x}` replacements * Email `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * misc `{x}` replacements * remove comments (makes searching for "{x}" nicer) * misc `{x}` replacements * JS `{x}` replacements * Cleanup language initialization * Change language constant + add pluralForm support * Misc language update things * Add script to find unused terms * Check all quote types * Remove most english translations from non-english languages * Also match with more args * Missed some apparently * Missed some (more) apparently * Misc work * Add script to convert *all* language files to json * Fix language codes * Remove a lot of unused terms * Remove a lot more unused terms * Convert everything to JSON, delete old files, get installer working with new system * Fix general configuration language dropdown + email messages * Fix page load time, fix language term `set` method * Fix discord integration command * Misc * Misc * Uncomment RTL definition * Misc * Convert links * Convert links * Convert links * Convert links * Misc work (bolding, fixes, etc) * Style fix * Fix variable * Fix #2668 * Fix old page load timers * Fix installer group sync injector error * Convert integration language terms * Fix more integration language things * Re-add upgrade script language things * Resolve PR comments * Remove unnecessary date() * Resolve some PR issues * Fix endpoint * Style * Fix Semantic -> Fomantic * Fix Semantic -> Fomantic * Return locale short code, not language id/name Only the short code is interesting to the API, return short code in user info endpoint just like in the website info endpoint. Also renamed to locale because it's language + region * Revert "warn people to not translate old language files" This reverts commit 690b77afff5ff7cc2f931d3b49feaa9a9072002b. * Fix query when there are no filters * Update 200-pr12.php * Update footer.php * insert time into string using placeholder * Fix getDisplayname case * Clean username * PR suggestions * Include newly created language in converted languages (migration) * PR suggestions * PR suggestions * Update init.php * Fix default language Co-authored-by: samerton <samerton@users.noreply.github.com> Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl> Co-authored-by: Partydragen <adrian_kili@outlook.com>
2022-04-23 06:27:10 -07:00
$this->addError($this->_language->get('user', 'integration_identifier_already_linked', ['integration' => $this->getName()]));
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
return false;
}
}
return $validation->passed();
}
public function onRegistrationPageLoad(Fields $fields) {
if (Settings::get('mc_username_registration', '1', 'Minecraft Integration') != '1') {
return;
}
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
$username_value = ((isset($_POST['username']) && $_POST['username']) ? Output::getClean(Input::get('username')) : '');
$fields->add('username', Fields::TEXT, $this->_language->get('user', 'minecraft_username'), true, $username_value, null, null, 1);
}
public function beforeRegistrationValidation(Validate $validate) {
// Nothing to do here
}
public function afterRegistrationValidation() {
if (Settings::get('mc_username_registration', '1', 'Minecraft Integration') != '1') {
return;
}
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
$username = Input::get('username');
// Validate username
if (!$this->validateUsername($username)) {
return;
}
// Get minecraft UUID
$result = $this->getUuidByUsername($username);
if (count($this->getErrors())) {
return;
}
$this->_uuid = $result['uuid'];
// Validate identifier
if (!$this->validateIdentifier($this->_uuid)) {
return;
}
}
public function successfulRegistration(User $user) {
if (Settings::get('mc_username_registration', '1', 'Minecraft Integration') != '1') {
return;
}
2023-01-26 14:08:11 -08:00
2022-06-01 22:15:07 +02:00
$code = SecureRandom::alphanumeric();
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
$integrationUser = new IntegrationUser($this);
$integrationUser->linkIntegration($user, $this->_uuid, Input::get('username'), false, $code);
}
public function syncIntegrationUser(IntegrationUser $integration_user): bool {
$profile = ProfileUtils::getProfile($integration_user->data()->identifier);
if ($profile) {
$result = $profile->getUsername();
if (!empty($result)) {
$integration_user->update([
'username' => $result,
'last_sync' => date('U')
]);
return true;
}
}
return false;
}
/**
* Get minecraft UUID by username
*
* @param string $username
* @return array
*/
public function getUuidByUsername(string $username): array {
if (Settings::get('uuid_linking')) {
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
return $this->getOnlineModeUuid($username);
}
2023-01-26 14:08:11 -08:00
return ProfileUtils::getOfflineModeUuid($username);
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
}
/**
* Query mojang api to get online-mode UUID.
*
* @param string $username
* @return array
*/
public function getOnlineModeUuid(string $username): array {
$profile = ProfileUtils::getProfile(str_replace(' ', '%20', $username));
$mcname_result = $profile ? $profile->getProfileAsArray() : [];
if (isset($mcname_result['username'], $mcname_result['uuid']) && !empty($mcname_result['username']) && !empty($mcname_result['uuid'])) {
// Valid
2023-01-26 14:08:11 -08:00
return [
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
'uuid' => $mcname_result['uuid'],
'username' => $mcname_result['username']
];
}
2023-01-26 14:08:11 -08:00
// Invalid
$this->addError($this->_language->get('user', 'invalid_mcname'));
User Integrations systems (#2606) * Initial work for User Integrations systems * Convert a few endpoints to new user integration system * Finish minecraft part to new User Integration system * Fixes verify banner issue https://github.com/NamelessMC/Nameless/issues/2052 Fixes https://github.com/NamelessMC/Nameless/issues/2052 * Convert discord to new user integrations system * Update fields to show user integrations * Add user integrations to StaffCP user page / move over * Update UserInfo and Rename MinecraftVerify endpoint * Rework user listing endpoint * Password check never returns null * Add support for offline mode uuid * Fix documentation phpstan warnings * else if * remove die() * Revamp registration page * add integrations settings page * Convert authme & fix phpstan issues * refix settings page * Load uuid when user is loaded * Redirect user to complete required integrations * Fix translation for user connections page * Rework integrations registration in Register Endpoint Completes https://github.com/NamelessMC/Nameless/issues/2516 * make getIntegration ignore case sensitive * Update installer * Update upgrader script to convert users * Fix index for user integrations * Remove uuid from user data * Misc * Remove one unused query * Add event for integration linking, verify and unlink * Finish user transformer, Finish user integrations * Thx phpstan * Fix phpdocs * Fix user reports page * Remove validation banner * Change default field value * resolve samerton feedback * don't clean when inserting data * don't clean event data * remove more clean * increase reset_code length from 60 to 64 * pr13 confirmed * one more clean * Remove API verification setting * Register integrations edit permission * Resolve a few requested changes * Rework username and identifier validation * Add button to sync user integration * Fix Synchronisation text * Fix is verified term Co-authored-by: Robin <robinslot@hotmail.nl> Co-authored-by: Robin <robin+git@rkslot.nl>
2022-04-16 18:42:24 +02:00
return [];
}
}