FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » How to create new users via API and log them in
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to create new users via API and log them in [message #33436] Fri, 01 September 2006 10:43 Go to next message
magnalox is currently offline  magnalox   Germany
Messages: 4
Registered: September 2006
Karma: 0
Junior Member
Hi,
we are using FUDforum in an environment, where people already have a user profile and are logged-in.

To avoid multiple creation/log-in procedures, I would like to create a new user in FUDforum's database and log them in via PHP, whenever the user logs in in the main application.

What is the recommended procedure ?
To automate the log-in, I found a function mentioned here.

I haven't found a hint how to create a new user via API.

Any recommendations/examples ?
Thanks
Re: How to create new users via API and log them in [message #33440 is a reply to message #33436] Fri, 01 September 2006 19:59 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
To create users you need to use the fudapi.inc.php file inside the scripts/ directory that contains the fud_add_user() function.

FUDforum Core Developer
Re: How to create new users via API and log them in [message #33472 is a reply to message #33440] Sun, 03 September 2006 10:23 Go to previous messageGo to next message
magnalox is currently offline  magnalox   Germany
Messages: 4
Registered: September 2006
Karma: 0
Junior Member
Thanks, found that.

Now I'm able to create a session ID by using
$ForumSessionID = external_fud_login($UserID);
but how do I send them logged-in onto the main index page?

A
header('Location: http://...forum root../index.php?t=index&S='.$ForumSessionID);
still shows them logged out.

Btw, a function like
external_fud_login_bylogin($UserLogin)
would be nice. Logins are required to be unique, so I don't needed to retrieve the UserID first.

Regards

Edit:
Meanwhile I found out that it works when cookies are
disabled, because the cookie set by external_fud_login()
is using the wrong session-id. Disabling cookies in
the browser forces FUDforum to use the (correct) sessid
passed via URL.

The forum runs in forum.mysite.com, not www.mysite.com
like my own scripts, including the handover-script.

Should I prevent external_fud_login() from setting a
cookie somehow ?
I could temporarily overwrite $COOKIE_NAME, but thats
not a terribly beautiful solution.

Hmmm....

[Updated on: Sun, 03 September 2006 16:48]

Report message to a moderator

Re: How to create new users via API and log them in [message #33481 is a reply to message #33472] Mon, 04 September 2006 13:41 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
external_fud_login() should definitely be setting the correct session id. What makes you think it does not? The function creates a new session id, associates the user with it and sets a cookie with the given session id.

FUDforum Core Developer
Re: How to create new users via API and log them in [message #33502 is a reply to message #33481] Mon, 04 September 2006 20:20 Go to previous messageGo to next message
magnalox is currently offline  magnalox   Germany
Messages: 4
Registered: September 2006
Karma: 0
Junior Member
From checking your code, I agree, but:

If I'm disabling cookies in my browser (FF 1.5.0.6) it works because it takes the SID trasfered via URL.

When I'm enabling cookies, the SID in the cookie is different from the on I got from external_fud_login().

Apparently the forum takes the SID from the cookie, which is not the one I got. The index-page offers then the quick-login form.

Could it be that the cookie is not stored for the correct subdomain and index.php creates a new session(-ID)?

As I wrote, the code is called from www.mysite.com, the forum is running under forum.mysite.com.
Could that make a difference ?
Is there a way making the forum not using the cookie but the SID passed via URL ?

I checked $GLOBALS['COOKIE_NAME'], $GLOBALS['COOKIE_PATH'], $GLOBALS['COOKIE_DOMAIN'] all are set as defined in GLOBALS.php.

Regards
Re: How to create new users via API and log them in [message #33512 is a reply to message #33502] Tue, 05 September 2006 12:16 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
I suspect that is exactly what the problem. Your forum's cookie domain is probably set to forum.mysite.com and when you try to set a cookie for that via www.mysite.com it is rejected. To fix the problem, you need to to change the cookie domain to .mysite.com after that it should work.

FUDforum Core Developer
Re: How to create new users via API and log them in [message #33516 is a reply to message #33436] Tue, 05 September 2006 13:40 Go to previous message
magnalox is currently offline  magnalox   Germany
Messages: 4
Registered: September 2006
Karma: 0
Junior Member
Thanks again, I think that was it.

Testing can be a bit confusing here since cookies
can remain vaild across sessions if not deleted.

Regards
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Can I get only parts of the styles on this forum
Next Topic: Setting up Mailing list question
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 23:47:26 GMT 2024

Total time taken to generate the page: 0.02191 seconds