@Test public void createInvitationTest() { Invitation invitation = new Invitation("*****@*****.**"); invitation.addCase(testCase); assertTrue(invitation.caseIds.contains(testCase.id)); invitation.removeRCACase(testCase); assertFalse(invitation.caseIds.contains(testCase.id)); assertTrue(invitation.toString().contains("Invitation")); }
public static void getInvite(@Required @Email String email, String returnUrl) throws Throwable { if (validation.hasErrors()) { flash.error(Messages.get("web.invite.email.invalid")); params.flash(); } else { if (User.findByEmail(email) != null) { flash.error(Messages.get("web.invite.email.exists")); params.flash(); } else { // Create the invitation instance. String lang = Lang.get(); Invitation invite = new Invitation(); invite.email = email; invite.locale = lang; invite.insert(); flash.success(Messages.get("web.invite.success")); } } if (StringUtils.isBlank(returnUrl)) { Application.index(); } redirect(returnUrl); }
public static void inviteNewMember( @Required String nom, @Required String prenom, @Required String mail, @Required String langue) { try { String login = normalize(prenom) + '.' + normalize(nom); String url = ""; String signature = ""; String community = "Hypertopic"; // String mailGodfather = ""; String firstNameGodfather = ""; String lastNameGodfather = ""; int flag = -1; if (session.get("username").equals("admin")) { firstNameGodfather = "l'administrateur"; mailGodfather = "Hypertopic Team <*****@*****.**>"; } else { HashMap<String, String> infos = Ldap.getConnectedUserInfos(session.get("username")); mailGodfather = infos.get("mail"); firstNameGodfather = infos.get("firstName"); lastNameGodfather = infos.get("lastName"); firstNameGodfather = firstNameGodfather.substring(0, 1).toUpperCase() + firstNameGodfather.substring(1).toLowerCase(); lastNameGodfather = lastNameGodfather.substring(0, 1).toUpperCase() + lastNameGodfather.substring(1).toLowerCase(); } flag = Invitation.verifyMaliciousPassword(login, mail); if (flag == Invitation.ADDRESSES_MATCHE || flag == Invitation.USER_NOTEXIST) { System.out.println("invitenewmember"); try { url = "http://" + request.domain; if (request.port != 80) url += ":" + request.port; url += "/inscription?firstname=" + URLEncoder.encode(prenom, "UTF-8") + "&lastname=" + URLEncoder.encode(nom, "UTF-8") + "&email=" + URLEncoder.encode(mail, "UTF-8"); signature = Crypto.sign(prenom + nom + mail); url += "&signature=" + signature; System.out.println("url in inviteNewMember: " + url); } catch (UnsupportedEncodingException uee) { System.err.println(uee); } if (validation.hasErrors()) { render("Invitation/index.html"); } else { if (renderArgs.get("domainName") != null) { community = renderArgs.get("domainName").toString(); } System.out.println("I can arrive heeeeeeeeeeeeeeeeeeeeeeeeer"); if (langue.equals("fr")) { Mails.inviteFr( "Hypertopic Team <*****@*****.**>", mail, prenom, nom, url, community, firstNameGodfather, lastNameGodfather, mailGodfather); } else { Mails.inviteEn( "Hypertopic Team <*****@*****.**>", mail, prenom, nom, url, community, firstNameGodfather, lastNameGodfather, mailGodfather); } flash.success(Messages.get("invitation_success")); System.out.println("community: " + community); session.remove("nom"); session.remove("prenom"); session.remove("mail"); Invitation.invitation(); } } else { if (langue.equals("fr")) { flash.error(Messages.get("invitation_mailadresse_no_match")); } else { flash.error(Messages.get("invitation_mailadresse_no_match")); } Invitation.invitation(); } } catch (Exception e) { System.out.println("An exception occurred in Invitation.inviteNewMember"); e.printStackTrace(); render("Invitation/index.html"); } }