Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "Type Login is not a member of Object controller.Application".
- Error:(24, 196) type Login is not a member of object controllers.Application
- class login extends BaseScalaTemplate[play.twirl.api.HtmlFormat.Appendable,Format[play.twirl.api.HtmlFormat.Appendable]](play.twirl.api.HtmlFormat) with play.twirl.api.Template1[Form[Application.Login],play.twirl.api.HtmlFormat.Appendable] {
- Error:(27, 43) type Login is not a member of object controllers.Application
- def apply/*1.2*/(form: Form[Application.Login]):play.twirl.api.HtmlFormat.Appendable = {
- Error:(71, 36) type Login is not a member of object controllers.Application
- def render(form:Form[Application.Login]): play.twirl.api.HtmlFormat.Appendable = apply(form)
- Error:(73, 28) type Login is not a member of object controllers.Application
- def f:((Form[Application.Login]) => play.twirl.api.HtmlFormat.Appendable) = (form) => apply(form)
- package models;
- import com.avaje.ebean.Model;
- import javax.persistence.Entity;
- import javax.persistence.Id;
- @Entity
- public class User extends Model {
- @Id
- public String email;
- public String name;
- public String password;
- public User(String email, String name, String password) {
- this.email = email;
- this.name = name;
- this.password = password;
- }
- public Finder<String,User> find = new Finder<String,User>(
- String.class, User.class
- );
- public User authenticate(String email, String password) {
- return find.where().eq("email", email)
- .eq("password", password).findUnique();
- }
- }
- package controllers;
- import models.User;
- import play.data.Form;
- import play.mvc.Controller;
- import play.mvc.Result;
- import views.html.index;
- import views.html.login;
- public class Application extends Controller {
- public Result index() {
- return ok(index.render("hello"));
- }
- public Result login() {
- return ok(login.render(form(Login.class)));
- }
- public Result authenticate() {
- Form<User> loginForm = Form.form(User.class).bindFromRequest();
- if (loginForm.hasErrors()) {
- return badRequest(login.render(loginForm));
- } else {
- session().clear();
- session("email", loginForm.get().email);
- return redirect(
- routes.Application.index()
- );
- }
- }
- public class Login {
- public String email;
- public String password;
- public User user;
- public String validate() {
- user.authenticate(email, password);
- if (user == null) {
- return "Invalid user or password";
- }
- return null;
- }
- }
- }
- @(form: Form[Application.Login])
- <html>
- <head>
- <title>Zentasks</title>
- <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
- <link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("stylesheets/login.css")">
- </head>
- <body>
- <header>
- <a href="@routes.Application.index" id="logo"><span>Zen</span>tasks</a>
- </header>
- @helper.form(routes.Application.authenticate) {
- <h1>Sign in</h1>
- @if(form.hasGlobalErrors) {
- <p class="error">
- @form.globalError.message
- </p>
- }
- <p>
- <input type="email" name="email" placeholder="Email" value="@form("email").value">
- </p>
- <p>
- <input type="password" name="password" placeholder="Password">
- </p>
- <p>
- <button type="submit">Login</button>
- </p>
- }
- </body>
- </html>
- # Routes
- # This file defines all application routes (Higher priority routes first)
- # ~~~~
- # Home page
- GET / controllers.Application.index()
- GET /login controllers.Application.login()
- POST /login controllers.Application.authenticate()
- # Map static resources from the /public folder to the /assets URL path
- GET /assets/*file controllers.Assets.at(path="/public", file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement