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 » legacy support » symfony 1.2 » User accounts
User accounts [message #76146] Thu, 02 April 2009 15:35 Go to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
Hello, it's my first ever post on symfony forum.

I'm using sfGuardPlugin to manage login process and need to allow users to register and subsequently edit their account. I also have user profile for additional user properties as well as 2 other propel objects (through embedded forms) which need to be updated when user registers or edits their account.

How can I achieve account registration and updates with 4 separate propel objects without basing the account class on sfGuardUser? Is this possible?

Thank You
Jasmina
Re: User accounts [message #76155 is a reply to message #76146 ] Thu, 02 April 2009 16:36 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
Hi,

should be possible, but why would you wanna separate it? Theres no problem in referencing the sf_guard_user object regarding future plugin updates. Or what is your concern?

I went into trouble when i defined a many-to-many reference between user_profile and another table when it came to saving the form. But this may be based on a mistake I made.
http://forum.symfony-project.org/index.php/t/19968/

regards,
hasc
Re: User accounts [message #76170 is a reply to message #76155 ] Thu, 02 April 2009 18:08 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
I'm trying to get the user to edit their own account when they are logged in and I haven't worked out how to tell the form to use the currently logged in user.
Re: User accounts [message #76185 is a reply to message #76170 ] Thu, 02 April 2009 22:12 Go to previous messageGo to next message
lord77  is currently offline lord77
Messages: 15
Registered: March 2009
Junior Member
Hey it is the good topic for me

I also have sf_guard_user and another table called account_user like this for additional information :

  account_user:
    id:                        ~
    _attributes:               { phpName: sfGuardUserProfile }  
    user_id :                  { type: integer, required: true, foreignTable: sf_guard_user, foreignReference: id, onDelete: cascade }
    name:                      { type: varchar(255), required: true }
    familyname:                { type: varchar(255), required: true }
    photo:                     { type: varchar(255) }
    address:                   { type: varchar(255), required: true }
    tel:                       { type: integer, required: true }
    mobile:                    integer
    dob:                       { type: date, required: true }
    drink:                     integer
    bottles:                   integer
    in_club:                   { type: boolean, required: true, default: FALSE }
    created_at:                ~
    updated_at:                ~
    email:                     { type: varchar(80), required: true, index: yes }
    validate:                  { type: varchar(17), index: yes}


I would like to fill the two tables in the database in the same time by clicking on the button "Save"

How can I print the fields of the two forms on the same page, and how can I save the both.

Thanks for your answer
Re: User accounts [message #76212 is a reply to message #76146 ] Fri, 03 April 2009 14:44 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
@lord77
If account_user is the profile associated with sf_guard_user saving should work transparently. If you initialize the form:
settings.yml:
  sf_guard_plugin:
    profile_class:      AccountUser
    profile_field_name: column_name_referencing_sf_guard_user_id

action:
$this->form = new sfGuardUserForm();

template:
echo $form;

all attributes of account_user should be rendered with the default fields.


@jasminam
The id of the form must be present in the html form for editing. I did something like this:
<?php echo form_tag_for($form,'@user',array('id'=>'user'));?>
<?php echo $form['id'];?>

Mabe this documentation helps:
http://www.symfony-project.org/book/forms/1_2/en/04-Propel-I ntegration

regards,
hasc



Re: User accounts [message #76235 is a reply to message #76212 ] Fri, 03 April 2009 20:36 Go to previous messageGo to next message
lord77  is currently offline lord77
Messages: 15
Registered: March 2009
Junior Member
I think it is in the app.yml instead of settings.yml because it generate a big error ... what do you thnik about it? are you sure?

Thanks !
Re: User accounts [message #76236 is a reply to message #76235 ] Fri, 03 April 2009 20:46 Go to previous messageGo to next message
lord77  is currently offline lord77
Messages: 15
Registered: March 2009
Junior Member
No it is ok it works! I have my form with the fields of the two tables but before my form it generates this error :


Warning: Illegal offset type in C:\development\sfprojects\jobeet\lib\vendor\symfony\lib\plug ins\sfPropelPlugin\lib\widget\sfWidgetFormPropelChoice.class .php on line 103

Warning: Illegal offset type in C:\development\sfprojects\jobeet\lib\vendor\symfony\lib\plug ins\sfPropelPlugin\lib\widget\sfWidgetFormPropelChoice.class .php on line 103

Do you know what it is?

[Updated on: Fri, 03 April 2009 20:47]

Re: User accounts [message #76261 is a reply to message #76212 ] Sat, 04 April 2009 16:29 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
Thank you for pointing me in the right direction hasc. I'm now passing correct propel object through actions, and seems to be getting the right details.

The next bit is making sure that it saves correctly, as I've chained 2 other forms to be saved while saving the user and user profile.
Re: User accounts [message #76321 is a reply to message #76236 ] Mon, 06 April 2009 10:05 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
Hi lord.

mistake of me, i meant app.yml.

Maybe there's an error in the related object's __toString() method. I assume offste type is the type of object that is assigned to the array as key values. But i can't say for sure.

Regards,
hasc
Re: User accounts [message #77135 is a reply to message #76146 ] Tue, 21 April 2009 01:18 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
Now that I've got user editing in place, I would like to allow new users to register using the same sfGuardUser model/forms.

When I try to access new or create actions I get this message (in sfGuardAutho template secureSuccess.php):
"You don't have the required permission to access this page."

My module's security.yml is as follows:

new:
  is_secure: off
create:
  is_secure: off
all:
  is_secure: on


Any ideas?

Thanks
Jasmina
Re: User accounts [message #77169 is a reply to message #77135 ] Tue, 21 April 2009 11:54 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
I am not sure but... did you delete the cache?
Re: User accounts [message #77173 is a reply to message #77169 ] Tue, 21 April 2009 12:08 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
Well, I've cleared the cache with cc command if that's what you mean, and it's still the same.
Re: User accounts [message #77174 is a reply to message #77173 ] Tue, 21 April 2009 12:18 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
The configuration in your security.yml looks ok. Maybe you do some forwarding on secured actions or you have some custom settings in your routing.yml?
I would start with setting:
all:
  is_secure: off

and then enable the security explicitly for each action, to find out why access is currently restricted.

Regards,
hasc
Re: User accounts [message #77176 is a reply to message #76146 ] Tue, 21 April 2009 12:43 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
This is set by default in my main security.yml

default:
  is_secure: off


Module security is enabled in individual module security.yml files.
(I tried to have everything in the main file but couldn't get it to work, so I had to do it this way. It would be nice if it was all in one place.)

There are a lot of custom settings in routing.yml; these relate to account (same for the following actions with matching route names: new, edit, update, show):

account_new:
  url:              /account/new
  param:            { module: sfGuardUser, action: new}


When you say "forwarding on secured actions" do you refer to the code in actions?

I'll try with security settings turned off to see what happens.

Ta
Jasmina
Re: User accounts [message #77181 is a reply to message #77176 ] Tue, 21 April 2009 13:03 Go to previous messageGo to next message
jasminam  is currently offline jasminam
Messages: 27
Registered: February 2009
Location: London
Junior Member
Still the same even with
all:
  is_secure: off


Do I need to look further into sfGuardPlugin sfGuardUser settings, and what should I be looking for?
Re: User accounts [message #77184 is a reply to message #77181 ] Tue, 21 April 2009 13:18 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
Don't know what you expect to find there. I am sure that this is a configuration problem.

Turn is_secure: off for your application and for your modules. Clear the cache and try again. Normally you should be abled to access the actions then.

Maybe also manually clear the cache.
Edit user's profile on frontend app using admin generator [message #97896 is a reply to message #76146 ] Thu, 22 April 2010 17:42 Go to previous message
jorge.chavez  is currently offline jorge.chavez
Messages: 34
Registered: May 2009
Location: Monterrey, México
Member

Hi!

Recently I've been thinking on implementing the user's profile edition on my frontend app, for each user to edit their own profile... I tried to implement it using admin generator, and this is what the steps I took:

1. Enable sfGuardUser module on my settings.yml
2. Create directory structure for the module on my app/modules/
3. Used config/generator.yml to display only certain fields to be edited, like this:

edit:
  title: Editing User "%%username%%"
  display:
    "Account": [username, password, password_again]
    "Profile": [first_name, middle_name, last_name]


My problem now is that when saving the form, the user object saved only contains the data from the fields displayed on the form, and overwriting all the other columns values already saved for that user on the db...

Am I missing something? Any kind of help would be greatly appreciated symfony community!!!

[Updated on: Tue, 27 April 2010 16:36]

Previous Topic:SFPropelMigrationLightPlugin
Next Topic:functional test with csrf
Goto Forum:
  

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