Hello,

I'm at the Point where I have 20 domains, but I have some Users which are from other Domains. Now I wanted them to register via whitelist or I register them over the Admin menu.

After I tried both versions, I come to the conclusion that it would'nt work.

So can you pls make something that the Admin is able to register users from other Domains or a email whitelist ?

example whitelist:
my.name@google.com
your.name@google.com

Comments

stylaone created an issue. See original summary.

stylaone’s picture

1.

Okay, I found an solution by myself. Maybe not the best, but one for now.

With that solution you can insert full E-Mail adresses and domains at the same time.

From Line 30

$mailDomain = explode('@', $form_state->getValue('mail'));
$mail = $form_state->getValue('mail');

From Line 40

$match = count(array_filter($domains, function($domain) use (&$mail, &$mailDomain) {
    return domain_registration_wildcard_match($domain, $mailDomain[1]) || 
           domain_registration_wildcard_match($domain, $mail);
    }
));

2.

A second solution would be to change two things. After that you can test both variants too.

Line 30

$mail = $form_state->getValue('mail');

and Line 68

return preg_match("#^" . strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.')) . "$#i", $string) || 
         preg_match("#^" . strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.')) . "$#i", explode('@', $string)[1]);
SMartin’s picture

styalone,

I'm a Newb and I need this functionality too :-)

Is your solution still working for you? Can you elaborate on how to implement it? Which file did you modify? Did you add the code above or change some existing code?

Thanks :-)

Simon

SMartin’s picture

I haven't tested this extensively but it seems that if you add the domain of the email address you want to set up an account for in this module, save the settings, create the account, then immediately remove the domain from settings again, the account will still be active and usable.

Hope that works for others...

S

pcambra’s picture

Status: Active » Needs work

I think this would be useful, does somebody want to post a patch for it?

rithesh bk’s picture

Assigned: Unassigned » rithesh bk

currently working on it ......

rithesh bk’s picture

Assigned: rithesh bk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.27 KB

Please find the updated patch .......

pcambra’s picture

Status: Needs review » Needs work

Thanks, a couple of comments:

  1. +++ b/domain_registration.module
    @@ -27,7 +27,7 @@ function domain_registration_user_register_validate(&$form, &$form_state) {
    +  $mailDomain = explode('@', $form_state->getValue('mail'));
    

    This should use snake case and not camel case.

  2. +++ b/domain_registration.module
    @@ -35,12 +35,12 @@ function domain_registration_user_register_validate(&$form, &$form_state) {
    +            return domain_registration_wildcard_match($domain, $mailDomain[1]) || domain_registration_wildcard_match($domain, $mail);
    

    Format of the code was fine already, and there are extra tabs here.

dhirendra.mishra’s picture

Status: Needs work » Needs review
StatusFileSize
new1.22 KB
new1.18 KB
pcambra’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
+++ b/domain_registration.module
@@ -27,7 +27,7 @@ function domain_registration_user_register_validate(&$form, &$form_state) {
-
+  $mail_domain = explode('@', $form_state->getValue('mail'));
   $mail = explode('@', $form_state->getValue('mail'));
 

Taking a second look here, it seems that mail_domain and mail variables have exactly the same values, mind explaining what are you trying to do here?

Please make sure you're testing the module after this change, we should probably add a test for this anyways.