OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace::UserAlterations Struct Reference

#include <SysCatalog.h>

Public Member Functions

bool wouldChange (UserMetadata const &user_meta) const
 
std::string toString (bool hide_password=true) const
 

Public Attributes

std::optional< std::string > passwd
 
std::optional< bool > is_super
 
std::optional< std::string > default_db
 
std::optional< bool > can_login
 

Detailed Description

Definition at line 116 of file SysCatalog.h.

Member Function Documentation

std::string Catalog_Namespace::UserAlterations::toString ( bool  hide_password = true) const

Definition at line 1126 of file SysCatalog.cpp.

References can_login, default_db, is_super, and passwd.

Referenced by Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider().

1126  {
1127  std::stringstream ss;
1128  if (passwd) {
1129  if (hide_password) {
1130  ss << "PASSWORD='XXXXXXXX'";
1131  } else {
1132  ss << "PASSWORD='" << *passwd << "'";
1133  }
1134  }
1135  if (is_super) {
1136  if (!ss.str().empty()) {
1137  ss << ", ";
1138  }
1139  ss << "IS_SUPER='" << (*is_super ? "TRUE" : "FALSE") << "'";
1140  }
1141  if (default_db) {
1142  if (!ss.str().empty()) {
1143  ss << ", ";
1144  }
1145  ss << "DEFAULT_DB='" << *default_db << "'";
1146  }
1147  if (can_login) {
1148  if (!ss.str().empty()) {
1149  ss << ", ";
1150  }
1151  ss << "CAN_LOGIN='" << *can_login << "'";
1152  }
1153  return ss.str();
1154 }
std::optional< std::string > passwd
Definition: SysCatalog.h:117
std::optional< std::string > default_db
Definition: SysCatalog.h:119
std::optional< bool > is_super
Definition: SysCatalog.h:118
std::optional< bool > can_login
Definition: SysCatalog.h:120

+ Here is the caller graph for this function:

bool Catalog_Namespace::UserAlterations::wouldChange ( UserMetadata const &  user_meta) const

Definition at line 1100 of file SysCatalog.cpp.

References Catalog_Namespace::UserMetadata::can_login, can_login, Catalog_Namespace::DBMetadata::dbId, default_db, Catalog_Namespace::UserMetadata::defaultDbId, Catalog_Namespace::SysCatalog::getMetadataForDB(), anonymous_namespace{SysCatalog.cpp}::hash_with_bcrypt(), Catalog_Namespace::SysCatalog::instance(), is_super, Catalog_Namespace::UserMetadata::isSuper, passwd, and Catalog_Namespace::UserMetadata::passwd_hash.

Referenced by Catalog_Namespace::SysCatalog::alterUser(), and Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider().

1100  {
1101  if (passwd && hash_with_bcrypt(*passwd) != user.passwd_hash) {
1102  return true;
1103  }
1104  if (is_super && *is_super != user.isSuper) {
1105  return true;
1106  }
1107  if (default_db) {
1108  DBMetadata db;
1109  if (!default_db->empty()) {
1111  throw std::runtime_error(string("DEFAULT_DB ") + *default_db + " not found.");
1112  }
1113  } else {
1114  db.dbId = -1;
1115  }
1116  if (db.dbId != user.defaultDbId) {
1117  return true;
1118  }
1119  }
1120  if (can_login && *can_login != user.can_login) {
1121  return true;
1122  }
1123  return false;
1124 }
std::optional< std::string > passwd
Definition: SysCatalog.h:117
std::optional< std::string > default_db
Definition: SysCatalog.h:119
std::optional< bool > is_super
Definition: SysCatalog.h:118
static SysCatalog & instance()
Definition: SysCatalog.h:341
std::string hash_with_bcrypt(const std::string &pwd)
Definition: SysCatalog.cpp:71
std::optional< bool > can_login
Definition: SysCatalog.h:120
bool getMetadataForDB(const std::string &name, DBMetadata &db)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::optional<bool> Catalog_Namespace::UserAlterations::can_login
std::optional<std::string> Catalog_Namespace::UserAlterations::default_db

The documentation for this struct was generated from the following files: