StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


12»»

How to log a user out/switch userExpand / Collapse
Author
Message
Posted 01/19/2007 5:29:45 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 7:31:07 PM
Posts: 1,241, Visits: 3,131
I need to both allow the user to log out (so another user can login) and handle session locking. I know the SessionLock.LockSession is used to do this sort of thing and session locking is on by default when a SF security project is created. What I'm confused about is what exactly happens. Here are some of the things I need to handle:

- session locks, user logs back in (this one is easy and already handled by LockSession)
- user logs off so another can log on (mostly used by testers), permission will likely be different.
- session locks, the user decides to close rather than unlock
- session locks, user has unsaved changes, decides to close
- session locks, another user logs on, original use has opened forms (maybe with pending edits), permissions might be different

So, suggestions on how to handle these cases?

Mainly, I'm wondering how permissions are handled with open form are shown when a different user unlocks the session, how to handle unsaved changes when a new user logs in or the user decides to exit first (of course, it might not be the user that was logged in that is exiting) and how to allow the application to close form a locked session.

Thanks!

Post #5981
Posted 01/20/2007 6:48:43 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 2:02:58 PM
Posts: 644, Visits: 10,954
Hi Greg.

I think this is nicely handled by the framework.

In my application's MainForm ToolStrip, I've created a "Login" button, with the following code:

Private Sub tsmiLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmiLogin.Click

    System.Windows.Forms.SendKeys.Send("{F11}")

End Sub

F11 is the SF shortcut to your Login form.

So, the user can live after pressing "Login" and the login form will be waiting for the next.

session locks, user logs back in (this one is easy and already handled by LockSession)

That's it.


user logs off so another can log on (mostly used by testers), permission will likely be different.

No problem. Permissions will be tested when new user logs in. Let's say there was an open form, which has its "ViewSecurityKey" set, if the new user hasn't got permission to view this form, a panel will be covering it keeping the user from viewing anything that was going on.

session locks, the user decides to close rather than unlock

I guess an authorized user will need to login and close the application. If there are any forms this user is not allowed to see, he probably won't be able to close the application. An authorized user will need to login first.

session locks, user has unsaved changes, decides to close

If the user that logs in back is authorized to do so, he can then just close it.

session locks, another user logs on, original use has opened forms (maybe with pending edits), permissions might be different

Think I described this scenario already.

Guess you will get deeper explanations from the guys.

Have a nice weekend.

Cheers.

Post #5988
Posted 01/20/2007 9:22:15 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
Thanks Ivan!   One other thing you can do to manually lock a session is this:

MicroFour.StrataFrame.Security.SessionLock.LockSession()
Post #5990
Posted 01/20/2007 8:27:16 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 7:31:07 PM
Posts: 1,241, Visits: 3,131
Thanks for the info guys!

So, I'm understanding what is done better. There are two things I'd like to be able to do:

1. when a user logs off, loop through the forms and possibly save changes. Would I need to expose some of the BO functionality at the form level, like the EditingState and the Save method? Also, I'd probably need to do this in an event related to session locking. Would it be BeforeSessionLocks (or what ever it is called)? And where is a suggested good place (in code) to put this event handler?

2. Add the Exit button to the login form when a session gets locked, so the app can just be closed. I know the button is there, but it must be hidden when session locking occurs. How can I get to be shown when the session is locked?

Thanks again and have a good weekend...it's snowing here
Post #6000
Posted 01/21/2007 10:18:51 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
There are a lot of different ways you can handle your forms being closed and saving changes.  It could depend on how you are launching your forms.  We have a menu system wihtin our medical application that launches all forms, reports, etc.  So since we have a single point of launching, it makes it easy to add handlers or fill a collection of some kind.

In any case, one option is to loop through the forms collection in your MDI form.

For Each loForm As Form In Me.MdiChildren
    Try
       
With CType
(loForm, MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)
            .Save()
            .Close()
        
End
With
    
Catch ex As
Exception
   
End
Try
Next

How can I get to be shown when the session is locked?

Well, you can create a custom login form to do this.  But depending on your needs, this might not be the best place to close down your app.  Generally it is best to require the end-user to at least log back in first...but maybe not.  It just depends on your circumstances.

it's snowing here

Here too   We got about 8-10 inches yesterday!

Post #6006
Posted 01/21/2007 2:24:04 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 7:31:07 PM
Posts: 1,241, Visits: 3,131
OK, I see that I can setup a form to save any/all BOs on the form with the BaseForm.Save method. And likewise I can undo any changes with the BaseForm.Undo method. Cool, that is handled.

Interacting with the login form is not obvious though. I see that there is a AllowAppExit property, which is tied to the Exit button's Visible property. And clicking the exit button simply sets a DialogResult of cancel. When I call LockSession, how would I enable AllowAppExit and also if the user cancels the form via a click to Exit, does LockSession close the app?

Here too We got about 8-10 inches yesterday!

Nice! I'm nursing some blisters from some new snow boots I used to go snow shoeing yesterday, but it was glorious!
Post #6011
Posted 01/21/2007 5:25:31 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
does LockSession close the app?

No.  If you create a custom login form you can prevent the Exit button be being disable.  Or...create a button of your own to close down the application.

Post #6014
Posted 01/22/2007 12:09:33 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 7:31:07 PM
Posts: 1,241, Visits: 3,131
I sorry, I'm just not following this.

I have a custom login form. When the login form is shown initially, the Exit is shown and this returns a result of Cancel to the caller (within Login.ShowLoginAndAuthUser), which then returns false, with sets the e.ShowMainForm to false, which causes the app to exit (some where in SF code). I'm pretty sure this is right. The Login.ShowLoginAndAuthUser code must configure the login form to show the exit button using the AllowAppExit property.

When LockSession is called, it must do whatever it does to lock the session, set AllowAppExit to false, then open the login form. If I did show the exit button, LockSession would likely ignore the cancel result (I'm guessing).

The problem I'm having it that in both cases I don't interact with the login form directly at ALL. And the login form doesn't directly cause the application to exit in the first case. And when the session is locked, I'm assuming the form is opened in dialog mode (ShowDialog), so any code I put in place after locking the session won't be run until after the login form is gone. I must be missing something pretty obvious here, but, well, I'm missing it




Post #6043
Posted 01/22/2007 12:40:54 PM