HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.

embedding the username in URLs

edited December 2005 in Vanilla 1.0 Help
I am trying to integrate Vanilla with an existing user system. The only remaining hurdle is to forward links to a user in Vanilla to the corresponding user in the external system. I don't want to store the Vanilla ID in the external system. One way to make this possible is with an Apache rewrite rule that would recognize a request to view a username, and transform the URL to request to view the same user name in the external system. Unfortunately, links to users in Vanilla are by ID number, e.g., <account.php?u=1234>. Would it be possible to change the interface to also accept requests of the fom <account.php?n=mark>? And to change all links to users to use this username form instead of the userid form? Actually, I know it must be possible. Will you implement it? Will you accept a patch? By the way, the Apache rewrite rule would look something like RewriteRule ^/vanilla/account.php?n=(.*) /othersystem/user?login=$1 Thanks for considering this!

Comments

  • edited December 2005
    Just looked at the code. It would be pretty hard. Not impossible, but hard enough that I know better than to tackle it :D
  • I dont see why he'd implement it into the core as it's unnecessary for vanilla. I'm sure people would be greatful of it as an extension though.
  • Well, if it's an extension, it will be a Total Hack. The templates are coded with

    GetUrl($this->Context->Configuration, "account.php", "", "u", $this->User->UserID)
    

    So to be compatible with existing templates, the extension would need to modify the GetUrl method to look up the UserName whenever account.php was sent with a UserId. If you're loading a page with 20 usernames on it (like a list of discussions), that's 20 additional database calls! So I think to be feasible, the templates would need to be modified; I suppose one could have separate versions of templates for "pretty" user URLs and "ugly" user URLs, but that seems wrong. Having usernames in the URL is generally beneficial, since you can tell who you were looking up if you're looking in a browser history or the address bar history; and without it, it's impossible to integrate Vanilla with other services without modifying a database.

    If this change is not in core, it can't be really be done without creating Template Chaos. I'd be happy to write a patch if I knew it stood a chance of being accepted. If account.php supported the UserId interface and the proposed UserName interface, then we could just convert templates on an as-needed basis.

  • MarkMark Vanilla Staff
    You could attach to a delegate on the account.php page and have it redirect to your system's account page with the username in the querystring. Pretty simple, really.
  • This would look really nice in clean urls (and a lot more descriptive too).
  • Ah, I didn't know about the delegates. Thanks a lot, I'll look into it!
This discussion has been closed.