WIP. User authentication on user interface

This commit is contained in:
emeric
2014-07-08 19:39:49 +02:00
parent 4744111959
commit 3e96534e08
17 changed files with 370 additions and 76 deletions
+44
View File
@@ -0,0 +1,44 @@
#include "database/DatabaseHandler.hpp"
#include <Wt/Auth/PasswordService>
#include <Wt/Auth/Identity>
int main(void)
{
try
{
boost::filesystem::remove("test_user.db");
// Set up the database session
Database::Handler::configureAuth();
Database::Handler db("test_user.db");
Wt::Dbo::Transaction transaction(db.getSession());
Wt::Auth::Identity identity;
Wt::Auth::User user = db.getUserDatabase().registerNew();
std::cout << "User is valid = " << std::boolalpha << user.isValid() << std::endl;
user.setIdentity(identity.provider(), "toto");
std::cout << "User is valid = " << std::boolalpha << user.isValid() << std::endl;
std::cout << "Updating password" << std::endl;
db.getPasswordService().updatePassword(user, "This is my password");
// db.getSession().add( user );
std::cout << "Committing" << std::endl;
transaction.commit();
}
catch(std::exception& e)
{
std::cerr << "Caught exception " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}