OmniSciDB  a5dc49c757
 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 1194 of file SysCatalog.cpp.

References can_login, default_db, is_super, and passwd.

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

1194  {
1195  std::stringstream ss;
1196  if (passwd) {
1197  if (hide_password) {
1198  ss << "PASSWORD='XXXXXXXX'";
1199  } else {
1200  ss << "PASSWORD='" << *passwd << "'";
1201  }
1202  }
1203  if (is_super) {
1204  if (!ss.str().empty()) {
1205  ss << ", ";
1206  }
1207  ss << "IS_SUPER='" << (*is_super ? "TRUE" : "FALSE") << "'";
1208  }
1209  if (default_db) {
1210  if (!ss.str().empty()) {
1211  ss << ", ";
1212  }
1213  ss << "DEFAULT_DB='" << *default_db << "'";
1214  }
1215  if (can_login) {
1216  if (!ss.str().empty()) {
1217  ss << ", ";
1218  }
1219  ss << "CAN_LOGIN='" << *can_login << "'";
1220  }
1221  return ss.str();
1222 }
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 1168 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().

1168  {
1169  if (passwd && hash_with_bcrypt(*passwd) != user.passwd_hash) {
1170  return true;
1171  }
1172  if (is_super && *is_super != user.isSuper) {
1173  return true;
1174  }
1175  if (default_db) {
1176  DBMetadata db;
1177  if (!default_db->empty()) {
1179  throw std::runtime_error(string("DEFAULT_DB ") + *default_db + " not found.");
1180  }
1181  } else {
1182  db.dbId = -1;
1183  }
1184  if (db.dbId != user.defaultDbId) {
1185  return true;
1186  }
1187  }
1188  if (can_login && *can_login != user.can_login) {
1189  return true;
1190  }
1191  return false;
1192 }
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:343
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: