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 8259067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:45:59+00:00 2026-06-08T02:45:59+00:00

I have the task of maintaining a small application written with PlayFramework 1.2.x. One

  • 0

I have the task of maintaining a small application written with PlayFramework 1.2.x. One item that needs done: adding a Captcha to the login page. This is apparently harder than one thinks, since the login-page is handled semi-automatically by the Secure module.

When handling a normal HTTP form, the PlayFramework passes the form variables to the controller method as parameters. Using the standard Secure module, the login form contains only the user-name and the password, and these are passed to the authenticate method.

Now, I can create a custom login-form that includes a captcha, and I am also allowed to override the authenticate method in the Secure module. The problem is this: I cannot change the parameters of the authenticate method to include the captcha-code, or else it is no longer overriding the method in the superclass (and the method is then never called).

Here is a simple login form, with the Captcha adapted from the “yabe” example:

#{extends 'main.html' /} #{set title:'Login' /}

#{form @authenticate()}

<p>
    <label for="username">User name: </label> <input type="text"
        name="username" id="username" maxlength="30"
        value="${params.username}" />
</p>
<p>
    <label for="password">Password: </label> <input type="password"
        name="password" id="password" maxlength="30" " />
</p>
<p>
    <label for="code">Please type the code below: </label> <img
        src="@{Captcha.captcha(randomID)}" /> <br /> <input type="text"
        name="code" id="code" size="18" value="" /> <input type="hidden"
        name="randomID" value="${randomID}" />
</p>
<p>
    <input type="submit" id="signin" value="Log in" />
</p>

#{/form}

Here is a simple authenticate method that does not work, because “code” and “randomID” are undefined. Again, I cannot just add the parameters to authenticate, or else it no longer overrides the method from the superclass, and is not called.

package controllers;

import play.cache.Cache;
import play.data.validation.Required;
import models.*;

public class Security extends Secure.Security {


    static boolean authenticate(String username, String password) {
        boolean auth = false;
        if (code.equals(Cache.get(randomID))) {
            auth = (User.connect(username, password) != null);
        }
        return auth;
    }
}

Question: how can I get the values “code” and “randomID” from the form to the authenticate method? Is there some other way of accessing values from the form?

  • 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-08T02:46:00+00:00Added an answer on June 8, 2026 at 2:46 am

    You are in a Play! controller, so you have access to the object request.params, out of which you can fetch the parameters, as in request.params.get("code").

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the task of maintaining an application that started life as a VB6
I have the unenviable task of maintaining an ActiveX control that expects OLE_Colors as
I have task involving reading SAS .xpt files using .NET. For that I'm using
I have a task to do, I need to take data that has been
I have a task that runs periodically 10 second. I do some picturebox refreshing
I have task to prepare two windows with swing. One contains grid of squares,
I have: Task Entity that holds a foreignkey to a Project Entity. In the
I have a task to develop the application related to address and access the
I have task schedule for backup directory list of wwwroot. For that I have
I have created one application in iphone sdk. i have already taken user credit

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.