Browser does not remember password during login

后端 未结 5 1636
天命终不由人
天命终不由人 2021-01-06 00:36

An earlier question mentioned a method using the el config in order to make the browser remember passwords. Howewer, the el config no longer exists

5条回答
  •  -上瘾入骨i
    2021-01-06 01:39

    The answer from lagnat was mostly correct, to get this also working on Chrome and Firefox the following is required:

    1) Override default ExtJS Textfield behavior for autocomplete (copied from lagnat):

    Ext.define('ACField', {
        extend: 'Ext.form.field.Text',
    
        initComponent: function() {
            Ext.each(this.fieldSubTpl, function(oneTpl, idx, allItems) {
                if (Ext.isString(oneTpl)) {
                    allItems[idx] = oneTpl.replace('autocomplete="off"', 'autocomplete="on"');
                }
            });
            this.callParent(arguments);
        }
    });
    

    2) Make sure the textfields are within a

    tag: (see answer from lagnat), since ExtJS 4 the tag is no longer present in a FormPanel.

        autoEl: {
            tag: 'form',
            action: '/j_spring_security_check',
            method: 'post'
        },  
    

    3) Make sure there is a present in the HTML, with the same names:

                items:[
                    Ext.create('ACField',{
                        fieldLabel: 'Username',
                        name:'j_username',
                        inputId: 'username',
                        allowBlank:false,
                        selectOnFocus:true
                    }),
                    Ext.create('ACField',{
                        fieldLabel:'Password',
                        name:'j_password',
                        inputId: 'password',
                        xtype:'textfield',
                        allowBlank:false,
                        inputType:'password'
                    })
                ],
    

    and within the HTML the regular form with same input names:

    
    
    " method="post">

    With all these changes in place, saving username/password works in IE, Chrome and Firefox.

提交回复
热议问题