Package com.secretpal.model

Examples of com.secretpal.model.SPPerson


  public WOActionResults loginAction() {
    session().logout();
   
    String emailAddress = request().stringFormValueForKey("emailAddress");
    String password = request().stringFormValueForKey("password");
    SPPerson person = SPPerson.fetchSPPerson(ERXEC.newEditingContext(), SPPerson.EMAIL_ADDRESS.is(emailAddress).and(SPPerson.PASSWORD.is(SPPerson.hashPassword(password))).and(SPPerson.PASSWORD.isNotNull()));
    WOActionResults nextPage;
    if (person != null) {
      session().setCurrentPerson(person);
      nextPage = pageWithName(SPHomePage.class);
    } else {
View Full Code Here


    String resetPasswordCode = request().stringFormValueForKey(SPUtilities.RESET_PASSWORD_CODE_KEY);
    if (resetPasswordCode == null || resetPasswordCode.trim().length() == 0) {
      session().errors().addNotice("You must provide a reset code to change your password.");
      nextPage = pageWithName(Main.class);
    } else {
      SPPerson person = SPPerson.fetchSPPerson(editingContext, SPPerson.PASSWORD.is(resetPasswordCode));
      if (person == null) {
        session().errors().addNotice("The reset code you are using is invalid.");
        nextPage = pageWithName(Main.class);
      } else {
        SPResetPasswordPage resetPasswordPage = pageWithName(SPResetPasswordPage.class);
View Full Code Here

    return sentEmail;
  }

  public static boolean sendResetPasswordEmail(SPPerson person, WOContext context, SPNoticeList errorNoticeList) {
    EOEditingContext editingContext = ERXEC.newEditingContext();
    SPPerson localPerson = person.localInstanceIn(editingContext);
    localPerson.resetPassword();
    editingContext.saveChanges();

    WOContext contextClone = (WOContext) context.clone();
    SPResetPasswordEmail resetPasswordEmail = ERXApplication.erxApplication().pageWithName(SPResetPasswordEmail.class, contextClone);
    resetPasswordEmail.setPerson(person);
View Full Code Here

    public void invalidRecipients(ERMessage message, NSArray<String> invalidRecipientAddresses) {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      editingContext.lock();
      try {
        SPPerson person = (SPPerson) ERXEOControlUtilities.convertGIDtoEO(editingContext, _personGID);
        _errorNoticeList.addNotice("Failed to send an email to '" + person.emailAddress() + "'.");
      } finally {
        editingContext.unlock();
        editingContext.dispose();
      }
    }
View Full Code Here

    public void deliverySucceeded(ERMessage message) {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      editingContext.lock();
      try {
        SPPerson person = (SPPerson) ERXEOControlUtilities.convertGIDtoEO(editingContext, _personGID);
        person.setEmailDeliveryFailure(Boolean.FALSE);
        editingContext.saveChanges();
      } finally {
        editingContext.unlock();
        editingContext.dispose();
      }
View Full Code Here

    public void deliveryFailed(ERMessage message, Throwable failure) {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      editingContext.lock();
      try {
        SPPerson person = (SPPerson) ERXEOControlUtilities.convertGIDtoEO(editingContext, _personGID);
        _errorNoticeList.addNotice("Failed to send an email to '" + person.emailAddress() + "'.");
        person.setEmailDeliveryFailure(Boolean.TRUE);
        editingContext.saveChanges();
      } finally {
        editingContext.unlock();
        editingContext.dispose();
      }
View Full Code Here

      return false;
    }
   
    public WOActionResults sendEmail() {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      SPPerson person = SPPerson.fetchSPPerson(editingContext, SPPerson.EMAIL_ADDRESS.is(_emailAddress));
      if (person != null) {
        SPUtilities.sendResetPasswordEmail(person, context(), session().errors());
      }
      session().notifications().addNotice("An password reset email has been sent to the email address you provided.");
      return pageWithName(Main.class);
View Full Code Here

  }

  public SPGroup group() {
    if (_group == null) {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      SPPerson currentPerson = session().currentPerson().localInstanceIn(editingContext);
      _group = SPGroup.createSPGroup(editingContext, "New Group", currentPerson);
      SPMembership.createSPMembership(editingContext, Boolean.TRUE, Boolean.TRUE, _group, currentPerson);
    }
    return _group;
  }
View Full Code Here

*/
public class SecretPal1 extends ERXMigrationDatabase.Migration implements IERXPostMigration {
  public void postUpgrade(EOEditingContext editingContext, EOModel model) throws Throwable {
    for (SPPerson person : SPPerson.fetchAllSPPersons(editingContext)) {
      EOEditingContext nestedEditingContext = ERXEC.newEditingContext(editingContext);
      SPPerson nestedPerson = person.localInstanceIn(nestedEditingContext);
      nestedPerson.setEmailAddress(SPUtilities.cleanseEmailAddress(nestedPerson.emailAddress()));
      try {
        nestedEditingContext.saveChanges();
      }
      catch (NSValidation.ValidationException e) {
        // this probably means the person realized they screwed up and reinvited the person with the proper email address
View Full Code Here

 
    sPSecretPalTable.addUniqueIndex("uniqueSecretPal", sPSecretPalTable.existingColumnNamed("eventID"), sPSecretPalTable.existingColumnNamed("giverID"), sPSecretPalTable.existingColumnNamed("receiverID"));
  }

  public void postUpgrade(EOEditingContext editingContext, EOModel model) throws Throwable {
    SPPerson admin = SPPerson.createSPPerson(editingContext, Boolean.TRUE, "admin@secretpal.com", Boolean.FALSE, "John Administrator");
    admin.setPlainTextPassword("adminadmin");
   
    SPPerson gary = SPPerson.createSPPerson(editingContext, Boolean.FALSE, "test1@secretpal.com", Boolean.FALSE, "Robert Test");
    gary.setPlainTextPassword("test1");
   
    SPPerson mary = SPPerson.createSPPerson(editingContext, Boolean.FALSE, "test2@secretpal.com", Boolean.FALSE, "Mary Example");
    mary.setPassword(null);
   
    SPGroup testGroup = SPGroup.createSPGroup(editingContext, "The Example Crew", admin);
    testGroup.setDescription("This is the example group for testing Secret Pal.");
    SPMembership.createSPMembership(editingContext, Boolean.TRUE, Boolean.TRUE, testGroup, admin);
    SPMembership.createSPMembership(editingContext, Boolean.FALSE, Boolean.TRUE, testGroup, gary);
View Full Code Here

TOP

Related Classes of com.secretpal.model.SPPerson

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.