Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

How to check if the user has logged in before allowing him to access the screens in the application?

HI

 

We have multiple screens in our blackberry UI application, around 8-10 screens.  The user can acess these screens once he enters his username and password on login screen. His username and password is then sent via email to the server where these username and password is verified and checked if the user has provided valid information.

 

Once the user has entered his username and password he can continue to access the screens in spite of not getting any reply / login successfull email from server. So, basically user can access screens even with wrong infomation till he gets failed login email from server.

 

Once user gets an email from server stating that the login details i.e. username and password were wrong user will be  logged out automatically and sent immidiately to login screen and will be asked to login again with valid username and password.

 

Now, before user gets login failed email he may already have accessed many screens and even though he was sent to login screen after receiving email he can hit back button in blackberry and continue to access those screens in the application.

 

We need to prevent user from accessing any of the application screens once he gets login failed message. The catch here is Off course he should be able to access the application even with wrong details till he gets login failed email.

 

Is there any way we can check if the user has login successfully before he is allowed to access any screen in the application? Something like we do in web application where we check for user in session. 

 

Please help !

 

Thanks

 

Highlighted
Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

[ Edited ]

Don't do it by email. Authenticate via HTTPS, or something, that you can determine whether a username or password is legitimate in near real time.

 

(Your constraints however seem contradictory: you want the user to be able to use your application without proper login credentials, but you want to lock the user out before you get an authentication response?)

Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Hi ydaraish 

 

Thanks for the reply.

 

Sorry if i sounded contradictory but its like this we want the user to be able to use our application without proper login credentials and user will be locked out only after we get an authentication failure response.

 

If we dont get any authentication response either success or failure for a very long time then the user will still continue to use application irrespective of login credentials.

 

Please advise as we are stuck and this is vey urgent !

 

 

Thanks

Ashish

 

 

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

What is the point of having username and password if the user can use the application without correct credentials?

 

If the authentication denied email goes to the device, you can monitor the incoming messages (look at the API documents, others can elaborate), otherwise, you will need to do something more sophisticated.

Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Hi ydaraishy

 

Currently we are monitoring for the incoming email message and if login is failed,  user is forwarded to the login screen.

 

What we want is that the user should not be able to hit back button and proceed further.

 

 

 

Any help in this regard will be apreciated.

 

 

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Do not just push the login screen, pop all the screens off the stack first.

Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Thanks for the answer.

 

I am still newbie in the blackberry. Could you please tell me how do we pop up all the screens from UIApplication?

 

We may not know the screens which are on the stack currently.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Can I suggest an alternative?

 

Have a shared Object, say in persistentStore, that specifies whether the user is authenticated or not (or pending).  Have your UiApplication check this, say whenever the user presses the menu button.  If it is pending, let the user continue, logged in, let them continue, or authentication failed, then issue a Dialog, exit the application and force them to log back in again.

 

Then in your email listener, you just set this shared object.

 

This saves you having to worry about context switching processes, popping screens or anything similar, and makes the process very easy to test.

Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Hi Peter

 

We do not have any menus in our application. All we have is buttons on all screens. Users can navigate from scren to screen using only these buttons. We have too many screens in our application. 

 

So do we have to check in fieldChanged method of all screens if the user is logged in ?

 

is there any way we can refactor this login checking code in common place so that we dont have to change all screns?

 

 

 

Developer
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers
My Carrier: Vodafone

Re: How to check if the user has logged in before allowing him to access the screens in the applicat

Hi Peter

 

Sorry i forgot to ask in earlier post that lets say if we check for login status and its failed. Even in this case how do we prevent user from proceeding to next screen?

 

 

public void fieldChanged(Field field, int context) {
		if (field == endBreakNow) {

                        if (login successfull){

			UiApplication.getUiApplication().pushScreen(new HomeScreen());
			UiApplication.getUiApplication().popScreen(this);
                        }else{

                        // prevent user from going further.
                        How?   
                        }

                }
        }