Esempio n. 1
0
void AuthService::verifyEmailAddress(const User& user, const std::string& address)
  const
{
  user.setUnverifiedEmail(address);

  std::string random = WRandom::generateId(tokenLength_);
  std::string hash = tokenHashFunction()->compute(random, std::string());

  Token t(hash,
	  WDateTime::currentDateTime().addSecs(emailTokenValidity_ * 60));
  user.setEmailToken(t, User::VerifyEmail);
  sendConfirmMail(address, user, random);
}
Esempio n. 2
0
void WsNewsLetter::createUser()
{
  bool knownEmail = false;
  //API call known email. Set the bool knownEmail
  if(knownEmail)
    return;

  if(emailLE_->validate() == WValidator::Invalid){
    new WText("Invalid mail.", this);
    return;
  }
  WString text = "";

  std::string random = WRandom::generateId(10);
  Auth::SHA1HashFunction hf;
  std::string hash = hf.compute(random, std::string());

  {
    dbo::Transaction transaction(session_);

    EmailToken *eToken = new EmailToken();
    eToken->email = emailLE_->text().toUTF8();
    eToken->token = hash;
    eToken->currentDate = WDate::currentDate();

    EmailTokens eTokens = session_.find<EmailToken>().where("email = ?").
        bind(emailLE_->text().toUTF8());
    session_.add(eToken);

    if(eTokens.size() != 0){
      //Print debug info to the screen.

      text += "rendom = ";
      text += random;
      text += " hash = ";
      text += hash;
      text += " Email token is already in db - it will be overwriten?";
      new WText(text, this);
    }
  }

  sendConfirmMail(emailLE_->text().toUTF8(),random);
}