This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » User management plugins » [RESOLVED] sfGuard login and extjs
[RESOLVED] sfGuard login and extjs [message #57593] Fri, 01 August 2008 17:42 Go to next message
drzen  is currently offline drzen
Messages: 21
Registered: March 2008
Location: Pordenone - Italy
Junior Member
Hi,

I'm trying to do a window login to sfGuard (signinSuccess.php) with extJs.
The attachment is my apps/fe/modules/sfGuardAuth

All go right but... not sucessufully login.
The problem seems public function executeSignin() and the correct response.

Someone can help me?

Thanks in advance.
v.

[Updated on: Mon, 01 September 2008 12:42]

Re: sfGuard login and extjs [message #57700 is a reply to message #57593 ] Sun, 03 August 2008 12:59 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Readers are unlikely to download the file and try it. Can you present some code in this thread, plus some reasons why you think it might not be working?


Remember Palestine
Re: sfGuard login and extjs [message #57721 is a reply to message #57700 ] Sun, 03 August 2008 21:09 Go to previous messageGo to next message
drzen  is currently offline drzen
Messages: 21
Registered: March 2008
Location: Pordenone - Italy
Junior Member

ok here some code:

The problem is the redirection after sucessufull login
action:
class sfGuardAuthActions extends BasesfGuardAuthActions
{
  public function executeSignin()
  {
    $user = $this->getUser();
    if($this->getRequest()->isXmlHttpRequest() == true)
    {
      $referer = $this->getRequest()->getReferer();
      $user->getAttributeHolder()->remove('referer');
      $signin_url = sfConfig::get('app_sf_guard_plugin_success_signin_url', $referer);

      $redirect = ('' != $signin_url) ? $signin_url : '@homepage';
      $redirect = $signin_url;

      $response = sprintf(
        '({"success":true, "redirect":"%s"})',
      $redirect
      );
      echo $response;
      return sfView::HEADER_ONLY;
    } else {
      parent::executeSignin();
    }
  }


template signinSuccess.php:
<script type="text/javascript">
  Ext.namespace('Login')
  Login = function(){
    var loginWindow, loginForm;
    return{
      init:function(){
        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'side';

        loginForm = new Ext.FormPanel({
          baseCls: 'x-plain',
          labelWidth: 145,
          url:'login',
          defaultType: 'textfield',
          title: '<b>Login Information</b>',
          bodyStyle:'padding:10px 0 0 15px',

          items: [{
            fieldLabel: 'Enter your Username',
            name: 'username',
            anchor:'90%',
            allowBlank:false
          },{
            fieldLabel: 'Enter your Password',
            name: 'password',
            anchor:'90%',
            allowBlank: false,
            inputType: 'password'
          }]
        });

        loginWindow = new Ext.Window({
          title: 'Login',
          width: 350,
          height:170,
          layout: 'fit',
          plain:true,
          closable: false,
          bodyStyle:'padding:5px;',
          buttonAlign:'center',
          items: loginForm
        });

        loginWindow.addButton('Login', Login.submitForm, Login);

        loginWindow.on('show', function(){
          var f = loginForm.items.item(0);
          f.focus.defer(100, f);
        });

        loginWindow.show(Ext.get('toolbar'));

        var usernameMap = new Ext.KeyMap(loginForm.items.item(0).getEl(), {
            key: Ext.EventObject.ENTER,
            fn: function(){loginForm.items.item(1).focus();}
        });

        var passwordMap = new Ext.KeyMap(loginForm.items.item(1).getEl(), {
            key: Ext.EventObject.ENTER,
            fn: Login.submitForm,
            scope: Login
        });
      },
      success: function(f,a){
        if(a && a.result){
          loginWindow.hide();
          window.location = a.result.redirect;
        }
      },
      submitForm: function(){
        loginForm.form.submit({
          waitMsg:'Logging in...',
          method: 'POST',
          clientValidation: true,
          success: Login.success,
          scope: Login
        });
      }
    }
  }();
  Ext.onReady(Login.init, Login, true);
</script>
[RESOLVED] Re: sfGuard login and extjs [message #59893 is a reply to message #57593 ] Mon, 01 September 2008 12:42 Go to previous message
drzen  is currently offline drzen
Messages: 21
Registered: March 2008
Location: Pordenone - Italy
Junior Member
In attach the correct code.

Previous Topic:sfGuard, groups & sfWidgetFormPropelSelect
Next Topic:sfGuard and sfPropel13
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software