Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove discord discriminator requirement #3374

Merged
merged 2 commits into from
Jun 13, 2023
Merged
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
12 changes: 7 additions & 5 deletions modules/Discord Integration/classes/DiscordIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package Modules\Core\Integrations
* @author Partydragen
* @version 2.1.0
* @version 2.1.1
* @license MIT
*/
class DiscordIntegration extends IntegrationBase {
Expand Down Expand Up @@ -81,12 +81,14 @@ public function validateUsername(string $username, int $integration_user_id = 0)
$validation = Validate::check(['username' => $username], [
'username' => [
Validate::REQUIRED => true,
Validate::REGEX => '/^.{2,32}#[0-9]{4}$/'
Validate::MIN => 2,
Validate::MAX => 32
]
])->messages([
'username' => [
Validate::REQUIRED => $this->_language->get('admin', 'integration_username_required', ['integration' => $this->getName()]),
Validate::REGEX => $this->_language->get('admin', 'integration_username_invalid', ['integration' => $this->getName()])
Validate::MIN => $this->_language->get('admin', 'integration_username_invalid', ['integration' => $this->getName()]),
Validate::MAX => $this->_language->get('admin', 'integration_username_invalid', ['integration' => $this->getName()])
]
]);

Expand Down Expand Up @@ -166,9 +168,9 @@ public function successfulRegistration(User $user) {
// Link integration if user registered using discord oauth
if (Session::exists('oauth_register_data')) {
$data = json_decode(Session::get('oauth_register_data'), true);
if ($data['provider'] == 'discord' && isset($data['data']['username']) && isset($data['data']['discriminator'])) {
if ($data['provider'] == 'discord' && isset($data['data']['username'])) {

$username = $data['data']['username'] . '#' . $data['data']['discriminator'];
$username = $data['data']['username'];
$discord_id = $data['data']['id'];
if ($this->validateIdentifier($discord_id) && $this->validateUsername($username)) {
$integrationUser = new IntegrationUser($this);
Expand Down