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

  • Home
  • SEARCH
  • 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 7794249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:43:33+00:00 2026-06-01T22:43:33+00:00

I have a IsAuthenticated method which has a complex argument type (I copied it

  • 0

I have a IsAuthenticated method which has a complex argument type (I copied it from play2’s zentasks example):

def IsAuthenticated(f: => String => Request[AnyContent] => Result): Action[(Action[AnyContent], AnyContent)] =
  Security.Authenticated(username, onUnauthorized) { userId =>
    Action { implicit request =>
      val email = request.session("user.email")
      f(email)(request)
    }
  }

In order to use it, my action is:

def delete(id:String) = IsAuthenticated { email => request =>
   ...
}

You can see I have to declare email event if I don’t need to use it. I can use _ instead:

def delete(id:String) = IsAuthenticated { _ => _ =>
   ...
}

But _ => _ => is still boring.

How to refactor the method to let it’s usage simpler? e.g. If I don’t need email and request, I can:

def delete(id:String) = IsAuthenticated {
   ...
}

If I just need request, I can:

def delete(id:String) = IsAuthenticated { request =>
   ...
}

If I need email, then I declare them all:

def delete(id:String) = IsAuthenticated { email => request =>
   ...
}
  • 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-06-01T22:43:34+00:00Added an answer on June 1, 2026 at 10:43 pm

    You can overload the IsAuthenticated to provide the different flavours you need. For example:

    def IsAuthenticated(result: => Result) = IsAuthenticated { _ => _ => result }
    

    You can then use it as follows:

    def delete(id:String) = IsAuthenticated {
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my controller action method: if (User.Identity.IsAuthenticated) { //
I have a web application, which has Servlet and a static Class accessed through
I have a method which registers a vote for a comment. If there are
I have helper method which is only checking if User is Authenticated but its
I have a method named raise_alarm() which, show a message box based on jquery.
I have a controller action that checks this.User.Identity.IsAuthenticated What do you suggest how to
I have a controller like this : @Secured(['ROLE_USER','IS_AUTHENTICATED_FULLY']) def userprofile(){ def user = User.get(springSecurityService.principal.id)
Have 2 tables for example: In 1st: object & parent columns object | parent
I am working with an asp.net 2.0 site (call it site 1) which has
In our application we have implemented role-based forms authentication. This has been handled using

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.