0

I'm building a site for a client that already has a website through another CMS that they do not wish to move away from despite my best efforts to convince them otherwise.

This CMS does offer an api that allows for implementation for single sign on so I'm trying to set that up.

I've gotten as far as

    function mymodule_form_alter(&$form, &$form_state, $form_id)
    {
        if ($form_id == 'user_login') {
            $form['#submit'] = ['mymodule_login'];
        }
    }

    function mymodule_login($form, &$form_state)
    {
        exit('SUCCESS');
    }

But the success message is never shown.

Oh, I tried searching to see if there was already a module that implemented this but no such luck.

3 Answers 3

0

Is you module named mymodule? The prefix of the hooks has to be the same as the machine readable name of your module. After checking that, try clearing the cache. After that, is should work because the code looks all right.

1
  • It's not called mymodule but it was a simple search and replace to produce the above code. May 12, 2017 at 18:01
0

The issue was that I was inputting an incorrect username and password and it was not reaching any of the submit hooks because it was failing on the validate hooks. It seems that my logic needs to go there if it wants to supercede the default validation logic.

0

Have a look at user_external_login_register

Helper function for authentication modules. Either logs in or registers the current user, based on username. Either way, the global $user object is populated and login tasks are performed.

There is a good comment there about how to implement that type of external login flow. https://api.drupal.org/comment/13434#comment-13434

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.