* @param playerName the playername.
* @return true if the password was successfully reset.
*/
public boolean resetPassword(String playerName) {
boolean result = false;
Player player = getPlayer(playerName);
if ((player != null)
&& (player.getEmail() != null)
&& (player.getEmail().length() > 0)
&& (this.mailhostName != null)
&& (this.authMailUsername != null)
&& (this.authMailPassword != null)) {
EntityManager entityManager =
PersistenceManager.getInstance().getEntityManager();
EntityTransaction entityTransaction = entityManager
.getTransaction();
entityTransaction.begin();
player.setPassword(randomString(8));
entityManager.merge(player);
entityManager.flush();
entityTransaction.commit();
sendMail(player.getEmail(), "CreepSmash - new password for "
+ playerName, "Hi "
+ playerName
+ "! \n\r Here is Your new password "
+ "for playing CreepSmash on "
+ "www.creepsmash.de . "
+ "\n\r new password: "
+ player.getPassword(),
this.authMailUsername,
this.authMailUsername,
this.authMailPassword,
this.mailhostName);
result = true;