We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Keep changes to the login View between updates

How Do I?

David O'Neill's avatar
David O'Neill
3 posts
about 4 months ago
David O'Neill's avatar David O'Neill

I have updated the login view to no longer show the user name and password fields and force them to click a button to login via SSO. Is it possible to persist this change between updates, even if it has to be some custom JS to do it on page load is fine. Ideally there would be a setting that I can “Enable SSO Login” and provide a URL and the view would render a button for me, but any workaround would be appreciated.

       
Hop Studios's avatar
Hop Studios
481 posts
3 months ago
Hop Studios's avatar Hop Studios

You might be able to restrict permissions on the file. But it might get moved anyway.

I have the same question – and your solution, to make it a setting, seems pretty smart to me. But without the rest of an SSO solution, it would be odd for EE to include just that.

       
swierczek's avatar
swierczek
3 posts
3 months ago
swierczek's avatar swierczek

We’ve had this exact issue in the past, and our solution was to do all of the modifications via the core_boot hook by injecting custom JS. This should get you started:

// inject JS on the login page to add SSO button and tabs
// doing it here avoids core template changes to View/account/login.php
public function core_boot()
{
    if (REQ === 'CP' && $_SERVER['QUERY_STRING'] === '/cp/login') {
        require_once SYSPATH . 'ee/legacy/libraries/View.php';

        $view = new View();

        echo $view->script_tag('jquery/jquery.js');
        echo $view->script_tag('common.js');

        echo '[removed]' . file_get_contents(FCPATH .'js/admin/login-page-sso.js') . '[removed]';
    }
}

And the JS:

$(function () {
    var $form = $('form');
    var $fields = $form.find('fieldset');

    $form.prepend('\
        <div class="tab-wrap">\
            <div class="tab-bar">\
                <div class="tab-bar__tabs">\
                    <button type="button" class="tab-bar__tab js-tab-button active" rel="t-0">With SSO</button>\
                    <button type="button" class="tab-bar__tab js-tab-button" rel="t-1">With Password</button>\
                </div>\
            </div>\
            <div class="tab t-0 tab-open">\
                <a href="/?ACT=whatever" class="button button--primary button--large button--wide">Sign in with SSO</a>\
            </div>\
            <div class="tab t-1">\
            </div>\
        </div>\
    ');

    // move form elements to second tab
    $form.find('.tab.t-1').append($fields);
});
? 1
       
David O'Neill's avatar
David O'Neill
3 posts
3 months ago
David O'Neill's avatar David O'Neill

Thanks for your feedback on this guys! @swierczek thank you for your complete example, I will have a tinker around with that today.

       
annakylie's avatar
annakylie
1 posts
about 2 months ago
annakylie's avatar annakylie

All of you, I appreciate your thoughts on this. I will play around with your comprehensive example today; thank you. car games

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.