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

Form Submission error #36

Open
Leapfrognz opened this issue Mar 18, 2019 · 11 comments
Open

Form Submission error #36

Leapfrognz opened this issue Mar 18, 2019 · 11 comments

Comments

@Leapfrognz
Copy link

Leapfrognz commented Mar 18, 2019

Hi guys, I get the following when clicking the real me login form button

ERROR [UNKNOWN TYPE, ERRNO 404]: 
IN POST /home/RealMeLoginForm/
Line  in 

Trace
=====
SilverStripe\Dev\CliDebugView->renderTrace()
DetailedErrorFormatter.php:119

SilverStripe\Logging\DetailedErrorFormatter->output(404, , , , )
DetailedErrorFormatter.php:54

SilverStripe\Logging\DetailedErrorFormatter->format(Array)
HTTPResponse.php:416

SilverStripe\Control\HTTPResponse->outputBody()
HTTPResponse.php:344

SilverStripe\Control\HTTPResponse->output()
index.php:27

SS4, module version 3.1.1

The documentation is light on how to add the form. I added this to my page Controller:

public function RealMeLoginForm()
    {
        $authenticator = \SilverStripe\Security\Security::singleton()->getAuthenticators();
        $handler = $authenticator['RealMe']->getLoginHandler($this->owner->Link('login'));
        $form = $handler->loginForm();
        return $form;
    }

The configuration seems to be in order. Note this is testing locally. But I should still get sent to mts through right?

@madmatt
Copy link
Member

madmatt commented Mar 18, 2019

Hey @Leapfrognz can you clarify what you're trying to do there? Are you wanting to embed the large login form in a different page, or use the mini login form?

Either way, you should just be able to do this in your PageController:

public function RealMeLoginForm()
{
    return new SilverStripe\RealMe\Authenticator\LoginForm($this, __FUNCTION__);
    // or return new SilverStripe\RealMe\Authenticator\MiniLoginForm($this, __FUNCTION__);
}

You'll need to add the usual private static $allowed_actions = ['RealMeLoginForm']; as well I think.

Let me know how you get on (note: I don't think we've extensively tested the mini login form on SS4, but I know the main login form should work embedded in a random page).

@madmatt
Copy link
Member

madmatt commented Mar 18, 2019

Also if the docs have led you astray at all, can you let me know where so I can tidy them up? Thanks!

@Leapfrognz
Copy link
Author

Leapfrognz commented Mar 18, 2019

Thanks Matt,

 return new SilverStripe\RealMe\Authenticator\LoginForm($this, __FUNCTION__);

This renders the same form so all good. The issue is with the submission - I get the error shown in my first post.
Interestingly I dont get the usual debug(), this looks different and doesnt give me any backtrace

@Leapfrognz
Copy link
Author

Also the Form method is Post. The docs say this should be GET?

<form id="LoginForm_RealMeLoginForm" action="/home/RealMeLoginForm/" method="post" enctype="application/x-www-form-urlencoded">

@madmatt
Copy link
Member

madmatt commented Mar 18, 2019

I'll double-check the dos, but there are two different login forms - the 'full' form (suitable for embedding on pages) and the 'mini' form (suitable for page headers/footers).

The full form (LoginForm) is POST, the mini form MiniLoginForm is GET. This is just because of the branding guidelines that RealMe has - we need to follow their HTML/CSS/JS specs precisely, and the HTML for the full form is a <button>, the mini login form is an <a> tag.

I haven't see that error you're seeing though which is pretty odd. There's nowhere specifically in the module where we return a 404 (I don't think at least).

What is the URL you're going to when you get the 404? Is it /home/RealMeLoginForm? If so, can you confirm you've added the private static $allowed_actions to PageController, and done a flush? I can't think of any other reason it wouldn't be working...

@Leapfrognz
Copy link
Author

Leapfrognz commented Mar 18, 2019

/home/RealMeLoginForm is correct, and private static $allowed_actions = ['RealMeLoginForm']; is there, and done a flush

@Leapfrognz
Copy link
Author

Leapfrognz commented Jul 12, 2019

@madmatt Im back onto this after being diverted onto other things for the past few months.
Unfortunately I'm still getting the same error.
I have tried this on a fresh install CWP setup as well:

composer

"require": {
        "cwp/cwp-recipe-cms": "^2.2",
        "cwp/cwp-recipe-core": "^2.2",
        "cwp/cwp-recipe-search": "^2.2",
        "silverstripe/realme": "3.1.2",
        "onelogin/php-saml": "dev-fixes/realme-dsig-validation as 2.11.0"
    },

PageController.php:

class PageController extends BasePageController
{
    private static $allowed_actions = [
        'RealMeLoginForm'
    ];

    public function RealMeLoginForm()
    {
        $auth = Injector::inst()->get(Authenticator::class);
        $handler = $auth->getLoginHandler($this->Link('login'));
        $form = $handler->loginForm();
        return $form;
    }
}

@Leapfrognz
Copy link
Author

Leapfrognz commented Jul 30, 2019

@madmatt
This is what we have working, may pay to update the docs:

<?php

use SilverStripe\Security\Security;
use SilverStripe\RealMe\Authenticator\LoginForm;
use CWP\CWP\PageTypes\BasePageController;

class PageController extends BasePageController
{
    private static $allowed_actions = [
        'RealMeLoginForm',
        'acs',
        'doLogin',
        'login'
    ];

    public function doLogin()
    {
        $authenticator = Security::singleton()->getAuthenticators();
        $handler = $authenticator['RealMe']->getLoginHandler('login');
        $handler->acs($this->request);
    }


    /**
     * Get RealMe login form for any page
     *
     * @return RealMeLoginForm
     */
    public function RealMeLoginForm()
    {
        return new LoginForm($this, __FUNCTION__);
    }
}

@robbieaverill
Copy link
Contributor

Pull requests are always welcomed

@Leapfrognz
Copy link
Author

Pull requests are always welcomed

Sure, But I want @madmatt to confirm this is the expected approach before updating the docs. Saves fuss.

@madmatt
Copy link
Member

madmatt commented Oct 23, 2019

I kinda think that the better option is to not list this directly, and just rely on using the Security/LoginForm - we could leave a comment that indicates you can do this if you want, but not specifically indicate the code required? Generally most people should just use Security/login... right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants