2016-07-12 6 views
0

playフレームワークで構築されたWebサイトのログイン機能を作成しようとしています。既存のユーザーの資格情報がhtmlビューに入力され、サブミット(ログイン)ボタンがクリックされると、ログイン・ページは何もしません。Play Frameworkでscalaを使用してログインできるようにすることができません

LoginController:

class LoginController @Inject() extends Controller { 

    def login(Email:String, password:String): Boolean = { 
     val user = CustomerLogin.findCustomer(Email).get 
     var status:Boolean = false 
     if(user.password == password) { 
     //log the user in 
     status = true 
     } else { 
     status = false 
     } 
     status 
    } 


    def index = Action { 
    implicit request => 
     Ok(views.html.loginOurs(LoginForm)) 
    } 


    private val LoginForm: Form[CustomerLogin] = Form(mapping(
    "Email" -> nonEmptyText, 
    "password" -> nonEmptyText)(CustomerLogin.apply)(CustomerLogin.unapply)) 


    def save = Action { 
    implicit request => 
     val newLoginForm = LoginForm.bindFromRequest() 
     newLoginForm.fold(hasErrors = { 
     form => 
      Redirect(routes.LoginController.index()).flashing(Flash(form.data) + 
      ("error" -> Messages("validation.errors"))) 
     }, success = { 
     newLogin => 
      Redirect(routes.HomeController.home()).flashing("success" -> Messages("customers.new.success", newLogin.Email))} 
    ) 
    } 


    def newLogin = Action { 
    implicit request => 
     val form = if(request2flash.get("error").isDefined) 
     LoginForm.bind(request2flash.data) 
     else 
     LoginForm 
     Ok(views.html.loginOurs(form)) 
    } 


} 

loginOurs.scala.html与えられた任意の助けをいただければ幸いです

GET  /login     controllers.LoginController.newLogin 

POST /login     controllers.LoginController.save 

GET /login/:Email    controllers.LoginController.login3(Email:String) 

GET  /login      controllers.HomeController.confirm(Email:String) 

(一部)

<div id="content"> 

    @main(Messages("login.form")) { 
    <h2>@Messages("login form")</h2> 
    @helper.form(action = routes.LoginController.save) { 
    <fieldset> 
     <legend> 
      @Messages("customer.details", Messages("customer.new")) 
     </legend> 
     @helper.inputText(LoginForm("Email")) 
     @helper.inputText(LoginForm("Password")) 
    </fieldset> 
    <p> 
     <input type="submit" class="btn-primary" value='@Messages("submit")'> 
    </p> 
    } 
    } 
</div> 

ルート(ログインのもののみ)。

感謝 ジャッキー

答えて

1

は、電子メールとパスワードのキャップのように注意してください、私は非常にあなたに感謝、働いはい

@helper.inputText(LoginForm("Email")) 
@helper.inputText(LoginForm("Password")) 

private val LoginForm: Form[CustomerLogin] = Form(mapping(
    "Email" -> nonEmptyText, 
    "password" -> nonEmptyText)(CustomerLogin.apply)(CustomerLogin.unapply)) 
+0

にミスマッチがあると思います多くのルイF –

関連する問題