Package uk.org.woodcraft.bookings.datamodel

Examples of uk.org.woodcraft.bookings.datamodel.User


  public String execute(){
   
    if(email == null || hash == null) return INPUT;
   
    User user = CannedQueries.getUserByEmail(email);

    if (user == null)
    {
      addActionError("User "+email+" was not recognised, please try again.");
      return INPUT;
    }
   
    if(!SignupUtils.checkEmailHash(user, hash))
    {
      addActionError("Unable to validate input for user, please try again");
      return INPUT;
    }
   
    if (user.getEmailValidated())
    {
      addActionMessage("User email has already been confirmed, no need to do this again.");
      return SUCCESS;
    }
   
    user.setEmailValidated(true);
    CannedQueries.save(user);
   
    if (user.getApproved())
    {
      addActionMessage("User email address was confirmed. You can now log in.");
    } else {
     
      addActionMessage("User email address was confirmed. Now awaiting admin approval - you will receive a further email when you have been granted access to the booking system by our staff.");
View Full Code Here


    assertDetached(transactions);
  }
 
  @Test
  public void testGetByKey() {
    User user1 = CannedQueries.getByKey(User.class, "globaladmin@example.com");
    assertEquals("Global Admin 1", user1.getName());
    assertDetached(user1);
   
    Organisation org = CannedQueries.orgByName("Woodcraft Folk");   
    Organisation org2 = CannedQueries.getByKey(Organisation.class, org.getKey());
    assertEquals(org, org2);
View Full Code Here

   
  }
 
  @Test
  public void testDelete() {
    User user1 = CannedQueries.getUserByEmail("globaladmin@example.com");
    assertEquals("Global Admin 1", user1.getName());
    assertDetached(user1);
   
    CannedQueries.delete(user1);
    User user1Deleted = CannedQueries.getUserByEmail("globaladmin@example.com");
    assertNull(user1Deleted);
  }
View Full Code Here

  }
  */
 
  @Test
  public void testSave() {
    User user1 = CannedQueries.getUserByEmail("globaladmin@example.com");
    assertEquals("Global Admin 1", user1.getName());     
    user1.setName("new name");
   
    CannedQueries.save(user1);
   
    User user1Renamed = CannedQueries.getUserByEmail("globaladmin@example.com");
    assertEquals("new name", user1Renamed.getName());
  }
View Full Code Here

  }
 
  public static User currentUser(boolean throwIfNotSignedIn)
  {
    ActionContext context = ActionContext.getContext();
    User user = null;
   
    // Fetch it from the session
    if(context != null)
      user = (User) ActionContext.getContext().getSession().get(SessionConstants.USER_HANDLE);
   
View Full Code Here

        session.put(key, value);
    }
  }
 
  public static User getAuditUser() {
    User user = SessionUtils.currentUser(false);
    if (user == null) user = CoreData.SYSTEM_USER;
   
    return user;
  }
View Full Code Here

      setModel(CannedQueries.getUserByEmail(email))
    }
   
    if (getModel() == null)
    {
      User user = new User();
      user.setIsNew(true);
   
      // Take the defaults from the current session
     
      Unit userAddedUnit = (Unit)getSessionObject(SessionConstants.CURRENT_UNIT);
      if (userAddedUnit != null) {
        // use the org of the unit if possible so we get consistency
        user.setOrganisationKey(userAddedUnit.getOrganisationKey());
        user.setUnitKey(userAddedUnit.getKey());
        return;
      }
    }
  }
View Full Code Here

    setEmail(getModel().getEmail());
    return changePasswordGeneric();
  }
 
  public String changePasswordGeneric() {
    User user = (User) getModel();
    if (user == null) return ERROR;
   
    SecurityModel.checkAllowed(Operation.WRITE, user);
   
    if (oldPassword == null && newPassword == null) return INPUT;
   
    if (!getCurrentUser().getAccessLevel().getIsSuperUser() && !user.checkPassword(oldPassword))
    {
      log.warn(String.format("%s Failed password change - wrong current password for %s", getRequestSource(), user.getEmail()));
      addActionError("Current password supplied is incorrect. Please try again");
      return INPUT;
    }
    if (newPassword == null || newPassword.length() == 0 )
    {
      log.info(String.format("%s Failed password change - missing new password for %s", getRequestSource(), user.getEmail()));
      addActionError("A new password must be supplied.");
      return INPUT;
    }
    if (!newPassword.equals(newPasswordConfirm))
    {
      log.info(String.format("%s Failed password change - new passwords didn't match for %s", getRequestSource(), user.getEmail()));
      addActionError("The new password and the confirmation of the new password must be the same.");
      return INPUT;
    }
   
    user.setPassword(newPassword);
    CannedQueries.save(user);
   
    log.warn(String.format("%s Password for %s changed", getRequestSource(), user.getEmail()));
    addActionMessage("Password for user '"+user.getName()+"' successfully changed.");
   
    return SUCCESS;
  }
View Full Code Here

  public static void createCoreData()
  {
    PersistenceManager pm = PMF.get().getPersistenceManager();
   
    // Annoyingly datanucleus won't let us use the copy up above...
    pm.makePersistent(new User(SYSTEM_USER_EMAIL, "System User", "", Accesslevel.NO_LOGIN));
   
    pm.close();
  }
View Full Code Here

TOP

Related Classes of uk.org.woodcraft.bookings.datamodel.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.