return proper authtokens object from pguser
This commit is contained in:
parent
cdf31fc1bf
commit
a5a3893415
@ -1,5 +1,8 @@
|
||||
#include <eedb/db/data/PgUser.hpp>
|
||||
|
||||
#include <eedb/db/data/PgAuthToken.hpp>
|
||||
//#include <eedb/db/data/Pg
|
||||
|
||||
#include <eedb/db/connection.hpp>
|
||||
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
@ -35,14 +38,21 @@ auto auth_token_info = user_auth_info.join(authToken).on(authToken.auth_info_
|
||||
namespace eedb {
|
||||
|
||||
struct PgUser::PgUserPriv {
|
||||
PgUserPriv(db::PgConnection & db, int uid, PgUser * owner) : _db{db}, id{uid}, self{owner} {}
|
||||
|
||||
void initAuthTokens() {
|
||||
_authTokens = std::make_unique< PgAuthTokens >(_db, self);
|
||||
}
|
||||
|
||||
db::PgConnection & _db;
|
||||
int id;
|
||||
PgUser *self;
|
||||
UserConfig config;
|
||||
|
||||
std::unique_ptr< PgAuthTokens > _authTokens;
|
||||
};
|
||||
|
||||
PgUser::PgUser(int uid) : _priv{spimpl::make_unique_impl< PgUserPriv >()} {
|
||||
_priv->id = uid;
|
||||
}
|
||||
PgUser::PgUser(db::PgConnection & db, int uid) : _priv{spimpl::make_unique_impl< PgUserPriv >(db, uid, this)} {}
|
||||
|
||||
int PgUser::uid() const {
|
||||
return _priv->id;
|
||||
@ -55,11 +65,14 @@ const UserConfig & PgUser::config() const {
|
||||
void PgUser::logout() {
|
||||
//
|
||||
}
|
||||
AuthTokens & PgUser::authTokens() const {}
|
||||
AuthTokens & PgUser::authTokens() const {
|
||||
if(!_priv->_authTokens)
|
||||
_priv->initAuthTokens();
|
||||
return *(_priv->_authTokens.get());
|
||||
}
|
||||
|
||||
AuthIdentities &PgUser::authIdentities() const {}
|
||||
AuthIdentities & PgUser::authIdentities() const {}
|
||||
|
||||
AuthInfo & PgUser::authInfo() const {}
|
||||
|
||||
} // namespace eedb
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ namespace eedb {
|
||||
|
||||
class PgUser : public User {
|
||||
public:
|
||||
PgUser(int uid);
|
||||
PgUser(db::PgConnection & db, int uid);
|
||||
|
||||
int uid() const override;
|
||||
|
||||
@ -21,17 +21,11 @@ class PgUser : public User {
|
||||
void logout() override;
|
||||
|
||||
AuthTokens & authTokens() const override;
|
||||
AuthIdentities &authIdentities() const override;
|
||||
AuthInfo &authInfo() const override;
|
||||
|
||||
private:
|
||||
struct PgUserPriv;
|
||||
spimpl::unique_impl_ptr< PgUserPriv > _priv;
|
||||
|
||||
// User interface
|
||||
public:
|
||||
AuthIdentities &authIdentities() const override;
|
||||
|
||||
// User interface
|
||||
public:
|
||||
AuthInfo &authInfo() const override;
|
||||
};
|
||||
} // namespace eedb
|
||||
|
||||
@ -44,7 +44,7 @@ unique_ptr< User > PgUsers::findWith(const AuthIdentity & identity) const {
|
||||
if(result.empty()) {
|
||||
return {};
|
||||
}
|
||||
return std::make_unique< PgUser >(result.front().user_uid);
|
||||
return std::make_unique< PgUser >(_priv->_db, result.front().user_uid);
|
||||
}
|
||||
|
||||
unique_ptr< User > PgUsers::findWith(const Email & email) const {
|
||||
@ -56,13 +56,10 @@ unique_ptr< User > PgUsers::findWith(const Email & email) const {
|
||||
if(result.empty()) {
|
||||
return {};
|
||||
}
|
||||
return std::make_unique< PgUser >(result.front().user_uid);
|
||||
return std::make_unique< PgUser >(_priv->_db, result.front().user_uid);
|
||||
}
|
||||
|
||||
unique_ptr<User> PgUsers::findWith(const EmailToken &token) const
|
||||
{
|
||||
|
||||
}
|
||||
unique_ptr< User > PgUsers::findWith(const EmailToken & token) const {}
|
||||
|
||||
// unique_ptr< User > PgUsers::findWith(const Users::AuthToken & token) const {
|
||||
// return {};
|
||||
@ -103,7 +100,7 @@ unique_ptr< User > PgUsers::addUser(unique_ptr< AuthInfo > authInfo, unique_ptr<
|
||||
t_auth_identity.identity = std::string{authIdentity->identity()},
|
||||
t_auth_identity.provider = std::string{authIdentity->provider()}));
|
||||
|
||||
return std::make_unique< eedb::PgUser >(user_id);
|
||||
return std::make_unique< eedb::PgUser >(_priv->_db, user_id);
|
||||
}
|
||||
|
||||
} // namespace eedb
|
||||
|
||||
Loading…
Reference in New Issue
Block a user