Ejemplo n.º 1
0
  @Security.Authenticated(RestaurantFilter.class)
  public static Result restaurant(String email) {
    List<Restaurant> restaurants = findR.all();
    User u = User.find(email);
    List<Meal> meals = Meal.allById(u);

    Restaurant restaurant = u.restaurant;
    List<TransactionU> tobeapproved = restaurant.toBeApproved;

    return ok(
        views.html.restaurant.restaurantOwner.render(
            email, meals, restaurant, restaurants, tobeapproved));
  }
Ejemplo n.º 2
0
 public static User loadUser() {
   return User.fetch(session().get("username"));
 }
Ejemplo n.º 3
0
 public String validate() {
   if (User.authenticate(email, password) == null) {
     return "Invalid user or password " + email + password;
   }
   return null;
 }
Ejemplo n.º 4
0
  public static Result editRestaurant(String email) {

    DynamicForm form = Form.form().bindFromRequest();
    User currentUser = Session.getCurrentUser(ctx());

    String hashedPassword = form.data().get("hashedPassword");
    String confirmPassword = form.data().get("confirmPassword");
    String name = form.data().get("name");

    if (!hashedPassword.equals(confirmPassword)) {
      flash("MatchPass", "Passwords don't match");
      return redirect("/restaurantOwnerEditProfile/" + name);
    }

    if (!hashedPassword.isEmpty()) {
      currentUser.hashedPassword = Hash.hashPassword(hashedPassword);
    }

    String city = form.data().get("city");
    String street = form.data().get("street");
    String number = form.data().get("number");
    double minOrder = Double.parseDouble(form.data().get("minOrder"));

    currentUser.restaurant.name = name;
    currentUser.restaurant.minOrder = minOrder;
    Location location = new Location(city, street, number);
    /*
    currentUser.location.city = city;
    currentUser.location.street = street;
    currentUser.location.number = number;
    currentUser.restaurant.update();
    currentUser.location.update();
    */
    currentUser.locations.add(location);
    currentUser.update();

    /*

    DynamicForm form = Form.form().bindFromRequest();

    User currentUser = Session.getCurrentUser(ctx());
    int id = currentUser.id;
    Restaurant restaurant = findR.byId(id);

    String userEmail = form.data().get("email");
    String userHashedPassword = form.data().get("hashedPassword");
    User.modifyUser(currentUser, userEmail, userHashedPassword);

    String name = form.data().get("name");
    Restaurant.modifyRestaurant(restaurant, userEmail, userHashedPassword, name);

    Location location =  restaurant.user.location;
    String city = form.data().get("city");
    String street = form.data().get("street");
    String number = form.data().get("number");

    Location.modifyLocation(location, city,street, number);
    location.save();
    restaurant.save();
    currentUser.save();
    */

    flash("successEdited", "You have successfully edited your restaurant Profile");

    return redirect("/restaurantOwner/" + email);
  }