#pragma once

#include <eedb/data/User.hpp>

namespace eedb::db {
class PgConnection;
}

namespace eedb {

class PgUserIdentity : public AuthIdentity {
    // UserIdentity interface
  public:
    PgUserIdentity(db::PgConnection & con, int uid, string provider);

    string_view identity() const override;
    string_view provider() const override;
  private:
    eedb::db::PgConnection & _db;
    string _name;
    string _provider;
    Email _email;
};

class PgUser : public User {
    // User interface
  public:
    const AuthIdentity & identity() const override;

    const UserConfig & config() const override;
    UserConfig & config() override;

    void changePassword(UserPassword & password) override;
    void login(UserPassword & password) override;
    void logout() override;
};
}
