Skip to content

Commit

Permalink
Remove Discord discriminator requirement (#3374)
Browse files Browse the repository at this point in the history
  • Loading branch information
partydragen authored Jun 13, 2023
1 parent 52e3196 commit faf13b2
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit faf13b2

Please sign in to comment.