#ifndef USER_HPP #define USER_HPP #include "master.hpp" #include "user_content.hpp" #include struct User; namespace apps { class user : public master { public: user( aCms &cms ); bool check_login( const std::string user, const std::string password ); bool user_exists( const std::string user ); void delete_user( const std::string user ); std::string registration_start( const std::string user, const std::string password, const std::string printName, const std::string email ); bool verify_registration_code( const std::string code ); User getUserData( const std::string username ); public: std::string last_captcha; std::string new_captcha; private: void login( ); void logout( ); void register_user( ); void confirm_register( ); void ini( content::user &c ); void api_users( ); void api_user( std::string username ); }; } // namespace user struct User { std::string name; std::string printName; std::string email; }; namespace cppcms { namespace json { template<> struct traits { static User get( value const &v ) { User u; if( v.type( ) != is_object) { throw bad_value_cast( ); } u.name = v.get( "name" ); u.printName = v.get( "printName" ); u.email = v.get( "email" ); return u; } static void set( value &v, User const &u ) { v.set( "name", u.name ); v.set( "printName", u.printName ); v.set( "email", u.email ); } }; } } // namespace cppcms::json #endif