Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:13:18+00:00 2026-05-25T10:13:18+00:00

In my play! app,I have coded the controllers.Security as class Security extends controllers.Secure.Security {

  • 0

In my play! app,I have coded the controllers.Security as

class Security extends controllers.Secure.Security {
...
   static void onDisconnected() {       
       Application.index();
   }
   static void onAuthenticated() {
      User user = User.find("byEmail",Security.connected()).first();
      if(user.isAdmin()) {
         Admin.index();
      }else {
          System.out.println("onAuthenticated()::user not admin");
   }
}

I have set the routes as

GET     /admin/?              Admin.index
*       /admin                module:crud
GET     /                    Application.index

When I am on a page say pageX and click on the login link,the login form appears and I am able to login.If I login as admin ,it takes me to the Admin.index() and thereby to Admin/index.html view.So far so good

But,when I am on pageX,and click on login link,I expect to come back to pageX.Instead ,the Application.index() method is called and I am taken to the Application.index.html..
Is this the expected behaviour?
What do I have to do to get to pageX after login?

update:

I tried storing the url in flash using the @Before in Security controller

class Security extends controllers.Secure.Security {
   @Before
   static void storeCurrentUrl() {
      System.out.println("storeCurrentUrl()");
      flash.put("url", "GET".equals(request.method) ? request.url : "/");
   }
   static boolean authenticate(String username, String password) {
   ...
   }

   static void onAuthenticated() {
      ...
      String url = flash.get("url");
      System.out.println("url="+url);
      if(!user.isAdmin()) {
         if(url!=null) {
        System.out.println("url not null");
        redirect(url);
     }else {
       System.out.println("url null  ..go to /");
       redirect("/");
    }
      }
   }

When I login,I get these terminal output

url=null
url null  ..go to /
index()

I have put the login/logout links in main.html template which is inherited by all other pages

<div id="main">
    <div class="auth">
     <a href="@{Admin.index()}">Go to Admin Area</a><br/><br/>
     <a href="@{Secure.login()}">Login</a><br/><br/>
     <a href="@{Secure.logout()}">Log out</a>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:13:19+00:00Added an answer on May 25, 2026 at 10:13 am

    In you controller, before calling ‘login()’ put the ‘url’ into flash something like:

    flash.put("url", "GET".equals(request.method) ? request.url : "/");
    

    Once successfully logged in, get the ‘url’ and redirect.

    String url = flash.get("url");
    redirect(url); //you may redirect to "/" if url is null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a singleton class in my play app. This singleton class is a
So I have an app where you play a game, and at the end
I'm using AVAudioPlayer to play music in my iPhone app. In a class that
I am using the AVAudioPlayer class to play .mp3 files in my App. Is
The problem: I have a legacy php app that is coded in no particular
I have an app which does listen and play sound at the same time.
I have the need to play multiple soundeffects at once in my WP7 app.
I have an app which plays a few short sound clips. To play them
I have an application from where a play a radio stream using a service
i try to off a sound effect on my app play method is '

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.