Authenticating in Play without using routes

I've followed this tutorial for authentication and it works:

http://www.playframework.com/documentation/2.2.x/JavaGuide4

But I was wondering if there was another way to do it so that the user can't just go to myapp.com/login and get the login screen even if they're already logged in. Is there a way to do this so I can go to the login screen but still have myapp.com as the route?

Answers


This is easy. Just have the controller method for route "/" display the login page instead of your landing page when the user is not logged in.

Say / routes to Application.index() and it has a function isLoggedIn() to check login status, you could do something like this:

public static index() {  

    if (isLoggedIn()) {  
        return ok (index.render());  
    }  
    else {  
        return ok (login.render());  
    }  
}  

Need Your Help

How to create a button to close active session in joomla 2.5

php session joomla content-management-system joomla2.5

I need to create a button to log out in Joomla, I mean, the user usually enter the session but then must press the button I created to close this session, I know how to check if any user has entere...

Data back when default dialer app is launched - Android

android android-intent

Does anyone know if the default dialer app in Android gives back any data which can be readed in onActivityResult() function? Something like this