diff options
Diffstat (limited to 'src/user.cpp')
-rw-r--r-- | src/user.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/user.cpp b/src/user.cpp index 8156ff0..6180c9d 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -35,6 +35,9 @@ user::user( strusCms &cms ) cms.dispatcher( ).assign( "/confirm_register", &user::confirm_register, this ); cms.mapper( ).assign( "confirm_register" ); + + cms.dispatcher( ).assign( "/api/users", &user::api_users, this ); + cms.mapper( ).assign( "api_users" ); } void user::login( ) @@ -115,6 +118,26 @@ void user::confirm_register( ) render( "confirm_register", c ); } + +void user::api_users( ) +{ + cppdb::session sql( cms.conn ); + cppdb::result r; + r = sql << "SELECT username, email FROM user"; + std::vector<User> users; + while( r.next( ) ) { + User user; + r >> user.name; + r >> user.email; + users.push_back( user ); + } + + cppcms::json::value j; + + j = users; + + response( ).out( ) << j; +} // TODO: make this a salted hash bool user::check_login( const std::string user, const std::string password ) |