use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class AbstractUserAndContractsController method submitCreateUserForm.
/**
* A new user can be created from the main form that can be accessed without
* being authentified. In this case, we check the validity of the filled-in
* url and we prevent the new users to be activated and created with admin
* privileges.
* On the other side, if the user is created from the admin interface, it can
* be set with activation and admin privileges info but the check of the url
* is useless cause the field has been removed from the form.
*
* @param createUserCommand
* @param result
* @param model
* @param successViewName
* @param errorViewName
* @param newUserFromAdmin
* @param successMessageKey
* @return
* @throws Exception
*/
protected String submitCreateUserForm(CreateUserCommand createUserCommand, BindingResult result, Model model, String successViewName, String errorViewName, boolean newUserFromAdmin, String successMessageKey) throws Exception {
createUserFormValidator.setCheckSiteUrl(!newUserFromAdmin);
// We check whether the form is valid
createUserFormValidator.validate(createUserCommand, result);
// If the form has some errors, we display it again with errors' details
if (result.hasErrors()) {
return displayFormWithErrors(model, createUserCommand, errorViewName);
}
User user;
if (!newUserFromAdmin) {
user = createUser(createUserCommand, false, false);
sendEmailInscription(user);
} else {
user = createUser(createUserCommand, true, true);
model.addAttribute(TgolKeyStore.USER_LIST_KEY, getUserDataService().findAll());
model.addAttribute(successMessageKey, user.getEmail1());
}
return successViewName;
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserFactoryImpl method create.
@Override
public User create(String email1, String password, String name, String firstName, String address, String phoneNumber, String webUrl1, String webUrl2, String identicaId, String twitterId, Role role, String email2) {
User user = create();
user.setEmail1(email1);
user.setPassword(password);
user.setName(name);
user.setAddress(address);
user.setFirstName(firstName);
user.setTwitterId(twitterId);
user.setIdenticaId(identicaId);
user.setWebUrl1(webUrl1);
user.setWebUrl2(webUrl2);
user.setRole(role);
user.setPhoneNumber(phoneNumber);
user.setEmail1(email2);
return user;
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImpl method findUserFromName.
@Override
public User findUserFromName(String name) {
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " left join fetch u.contractSet c" + " WHERE u.name = :name");
query.setParameter("name", name);
try {
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImpl method findUserFromEmail.
@Override
public User findUserFromEmail(String email) {
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " left join fetch u.contractSet c" + // + " left join fetch c.actSet a"
" WHERE u.email = :email");
query.setParameter("email", email);
try {
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class AbstractUserAndContractsController method createUser.
/**
* Create a user entit
* @param createUserCommand
* @return
* @throws Exception
*/
private User createUser(CreateUserCommand createUserCommand, boolean allowActivation, boolean allowAdmin) throws Exception {
User user = getUserDataService().create();
user.setEmail1(createUserCommand.getEmail());
user.setFirstName(createUserCommand.getFirstName());
user.setName(createUserCommand.getLastName());
user.setPhoneNumber(createUserCommand.getPhoneNumber());
user.setPassword(MD5Encoder.MD5(createUserCommand.getPassword()));
user.setWebUrl1(createUserCommand.getSiteUrl());
if (allowActivation) {
user.setAccountActivation(createUserCommand.getActivated());
} else {
user.setAccountActivation(false);
}
if (allowAdmin && createUserCommand.getAdmin()) {
user.setRole(CreateUserCommandFactory.getInstance().getAdminRole());
} else {
user.setRole(CreateUserCommandFactory.getInstance().getUserRole());
}
getUserDataService().saveOrUpdate(user);
return user;
}
Aggregations