@Bruno - That's true. But what would happen if two users register with
logins, username200 and username2000.  Both generates a login_slug equal to
username2-.  Same with the case of user-name and user_name. Both generates
user-name as the login_slug.

One option would be to change the format of user logins to
/^[A-Za-z0-9\_]+$/ which prohibits hyphens from being used. And change the
generate_login_slug to self.login_slug = self.login.gsub(/[^a-z0-9_]+/i,
'-').

@Bob - Change the generate_login_slug method to self.login_slug =
self.login.gsub(/[^a-z0-9]+/i, '-').

On Mon, Oct 5, 2009 at 11:43 PM, Bruno Bornsztein <
[email protected]> wrote:

> Chris: are you on an old version of CE? There's no code in
> FriendshipsController that looks like that.
> Jim: same question. User.rb validates_uniqueness of login_slug, so two
> users shouldn't be able to end up with the same slug.
>
>
> On Sun, Oct 4, 2009 at 9:54 PM, jim <[email protected]> wrote:
>
>>
>> This also happens when two users have the following usernames:
>>  user-name
>>  user_name
>> What happens is that they would have the same login_slug and whoever
>> registers first is the one returned by the find method.
>>
>> Just override the generate_login_slug method to fix this bug.
>>
>> def generate_login_slug
>>    self.login_slug = self.login.gsub(/[^a-z0-9_]+/i, '-')
>> end
>>
>>
>> On Oct 2, 3:40 am, Bruno Bornsztein <[email protected]>
>> wrote:
>> > Hi Chris,It may be a bug. To submit your changes (please make sure to
>> write
>> > passing tests that cover this scenario), just send me a pull request on
>> > GitHub or send a patch.
>> >
>> > Here's some more info:http://help.github.com/forking/
>> >
>> > Thanks!
>> > Bruno
>> >
>> > On Wed, Sep 30, 2009 at 7:38 PM, Christopher Becker <
>> [email protected]>wrote:
>> >
>> >
>> >
>> >
>> >
>> > > I have a user whose login ends with '5000'.  The url builder deals
>> with
>> > > this by making it '...5-' in the urls, fine.  But when I did invite a
>> friend
>> > > on this user, it actually created a friendship a completely different
>> > > user...WHAT?!   So I took a look at the controller/view and came up
>> with
>> > > these changes
>> > > for FrienshipsController.add_friend:was:         @friendship =
>> > > Friendship.new(:user_id => @user.id, :friend_id =>
>> > > User.find_by_login(params[:friend_id]).id, :initiator => true )
>> > > *became: @friendship = Friendship.new(:user_id => @user.id,
>> :friend_id =>
>> > > params[:friend_id], :initiator => true )*
>> > > *
>> > > *
>> > > Also changed my friendship link in the view:
>> > > *was:   user_add_friend_url(current_user, user)*
>> > > *became: user_add_friend_url(:user_id=>current_user.id, :friend_id=>
>> > > user.id)*
>> > > *
>> > > *
>> > > This is a bug right?  I'm not sure what the process is for working on
>> the
>> > > current dev branch but if someone can point me to a "getting started"
>> or
>> > > wiki or whatever I can look into adding this myself.
>> >
>> > > Cheers,
>> > > Chris
>>
>>
>
> >
>


-- 
"We do not believe in ourselves until someone reveals that deep inside us is
valuable, worth listening to, worthy of our trust, sacred to our touch." -
E. E. Cummings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to