scala - Binding form value in Play 2.5 -
i'm trying upgrade play 2.2 project play 2.5. have authentication works fine in play 2.2 if try implement same authentication in play 2.5 goes "unauthorized" page. think i'm having problem binding values of form. here code :
application.scala `
package controllers import javax.inject._ import play.api._ import play.api.mvc._ import views._ import models.users.user import models.users.userdb import models.users.userform import play.api.data.form import play.api.data.forms._ import play.api.i18n._ @singleton class application @inject()( userdb : user, val messagesapi: messagesapi ) extends controller i18nsupport { val userform : form[userform]= form ( mapping( "email" -> nonemptytext, "password" -> nonemptytext )(userform.apply)(userform.unapply)) def index = action { implicit request => ok(views.html.user.userlogin(userform)).withnewsession } def login = action { implicit request => userform.bindfromrequest.fold( errors=> badrequest(html.user.userlogin( errors)), user => { ok } ) } }` here userform case class :
case class userform(email : string, password : string) { } and here view userlogin :
@( userform: form[models.users.userform])(implicit flash: flash, messages: messages) @import helper._ . . . //other html stuff.... @form(action = routes.application.login()) { <div class="emailaddress">e-mail address:</div> <div class="inputbox"> @input(userform("email"), '_id -> "email", '_label->"" ) { (id, name, value, args) => <input placeholder="" type="text" class="email-input" id="@id" name="@name" value="" @tohtmlargs(args)> } </div> <div class="password">password:</div> <div class="inputbox1"> @helper.input(userform("password"), '_id -> "password", '_label->"") { (id, name, value, args) => <input placeholder="" class="password-input" type="password" id="@id" name="@name" value="" @tohtmlargs(args)> } </div> <div > <button id="submit-button" class="mybutton" >submit</button> </div> } @userform.globalerror.map { error => <p class="error"> @error.message </p> } i think problem in html file because tried repleace login method
def login = action { implicit request => ok } but bring me unauthorized page.
thanks.
Comments
Post a Comment