Exemplo n.º 1
0
Arquivo: Session.C Projeto: DTidd/wt
Session::Session()
  : sqlite3_(WApplication::instance()->appRoot() + "hangman.db")
{
  session_.setConnection(sqlite3_);
  sqlite3_.setProperty("show-queries", "true");

  session_.mapClass<User>("user");
  session_.mapClass<AuthInfo>("auth_info");
  session_.mapClass<AuthInfo::AuthIdentityType>("auth_identity");
  session_.mapClass<AuthInfo::AuthTokenType>("auth_token");

  users_ = new UserDatabase(session_);

  dbo::Transaction transaction(session_);
  try {
    session_.createTables();

    /*
     * Add a default guest/guest account
     */
    Auth::User guestUser = users_->registerNew();
    guestUser.addIdentity(Auth::Identity::LoginName, "guest");
    myPasswordService.updatePassword(guestUser, "guest");

    Wt::log("info") << "Database created";
  } catch (...) {
    Wt::log("info") << "Using existing database";
  }

  transaction.commit();
}
Exemplo n.º 2
0
WebAuth::WebAuth() : m_sqlite3(WApplication::instance()->appRoot() + "RTAutomationWeb.db")
{
    m_authSession.setConnection(m_sqlite3);
    m_sqlite3.setProperty("show-queries", "true");

    m_authSession.mapClass<WebUser>("user");
    m_authSession.mapClass<AuthInfo>("auth_info");
    m_authSession.mapClass<AuthInfo::AuthIdentityType>("auth_identity");
    m_authSession.mapClass<AuthInfo::AuthTokenType>("auth_token");

    m_users = new UserDatabase(m_authSession);

    dbo::Transaction transaction(m_authSession);
    try
    {
        m_authSession.createTables();

        Auth::User guestUser = m_users->registerNew();
        guestUser.addIdentity(Auth::Identity::LoginName, "richards-tech");
        WebPasswordService.updatePassword(guestUser, "richards-tech");

        qDebug() << "Database created";
    } catch (...) {
        qDebug() << "Using existing database";
    }

    transaction.commit();
}