Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Auto login
Primate
#1 Posted : Thursday, 8 October 2009 6:38:29 PM(UTC)
Rank: Member

Joined: 2/09/2009(UTC)
Posts: 5
Location: Thailand

I would like to use the same account for all users (except admin). How can I modify the application to automatically login to a default account unless explicitly logging in from the login page?
Roger Martin
#2 Posted : Thursday, 8 October 2009 11:35:26 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,301
Location: Fort Atkinson, WI

You would need to download the source code version and modify it to automatically log as your desired user.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Primate
#3 Posted : Friday, 9 October 2009 2:05:09 PM(UTC)
Rank: Member

Joined: 2/09/2009(UTC)
Posts: 5
Location: Thailand

I'm working with the source and figured out a way to do it already. I'll post my solution on Monday.

Thanks for this app Roger.
Primate
#4 Posted : Sunday, 11 October 2009 1:48:36 PM(UTC)
Rank: Member

Joined: 2/09/2009(UTC)
Posts: 5
Location: Thailand

Don't know if this will be of interest to anyone but here's what I did:

I turned off "Allow anonymous browsing" and "Show login / logout buttons on every page" and in the GalleryPage_Init method changed:

if (RequiresLogin())
Util.Redirect(PageId.login, true, "ReturnUrl={0}", Util.UrlEncode(Request.RawUrl));


to:

if (RequiresLogin())
//Util.Redirect(PageId.login, true, "ReturnUrl={0}", Util.UrlEncode(Request.RawUrl));
Controller.UserController.UserLoggedOn("user");


Where "user" is the name of the default account which I want logged in automatically.

If I need to login with a different account I can use the "?g=login" parameter.

Should probably also remove the "Log out" command from the "Actions" menu.

Bit of a hack because it breaks the application but works!
Roger Martin
#5 Posted : Sunday, 11 October 2009 1:56:47 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,301
Location: Fort Atkinson, WI

I can't argue with success, but I don't understand how your user is logged in. You should call UserLoggedOn() *after* authenticating a user, but you don't mention doing that. Here is the documentation for that function:

Quote:
/// <summary>
/// Contains functionality that must execute after a user has logged on. Specifically, roles are cleared from the cache
/// and, if user albums are enabled, the user's personal album is validated. Developers integrating Gallery Server into
/// their applications should call this method after they have authenticated a user. User must be logged on by the
/// time this method is called. For example, one can call this method in the LoggedIn event of the ASP.NET Login control.
/// </summary>
/// <param name="userName">Name of the user that has logged on.</param>

Roger Martin
Creator and Lead Developer of Gallery Server Pro
Primate
#6 Posted : Monday, 12 October 2009 6:38:04 PM(UTC)
Rank: Member

Joined: 2/09/2009(UTC)
Posts: 5
Location: Thailand

Yes, you are right, it's not working. Still don't know how I can automatically authenticate a default user.
Primate
#7 Posted : Monday, 12 October 2009 6:52:00 PM(UTC)
Rank: Member

Joined: 2/09/2009(UTC)
Posts: 5
Location: Thailand

OK, done it. Just had to call UserController.LogOnUser instead of Controller.UserController.UserLoggedOn. Makes sense!

Thanks for pointing me in the right direction.
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.