OmniSciDB  a987f07e93
 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 1181 of file SysCatalog.cpp.

References can_login, default_db, is_super, and passwd.

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

1181  {
1182  std::stringstream ss;
1183  if (passwd) {
1184  if (hide_password) {
1185  ss << "PASSWORD='XXXXXXXX'";
1186  } else {
1187  ss << "PASSWORD='" << *passwd << "'";
1188  }
1189  }
1190  if (is_super) {
1191  if (!ss.str().empty()) {
1192  ss << ", ";
1193  }
1194  ss << "IS_SUPER='" << (*is_super ? "TRUE" : "FALSE") << "'";
1195  }
1196  if (default_db) {
1197  if (!ss.str().empty()) {
1198  ss << ", ";
1199  }
1200  ss << "DEFAULT_DB='" << *default_db << "'";
1201  }
1202  if (can_login) {
1203  if (!ss.str().empty()) {
1204  ss << ", ";
1205  }
1206  ss << "CAN_LOGIN='" << *can_login << "'";
1207  }
1208  return ss.str();
1209 }
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 1155 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().

1155  {
1156  if (passwd && hash_with_bcrypt(*passwd) != user.passwd_hash) {
1157  return true;
1158  }
1159  if (is_super && *is_super != user.isSuper) {
1160  return true;
1161  }
1162  if (default_db) {
1163  DBMetadata db;
1164  if (!default_db->empty()) {
1166  throw std::runtime_error(string("DEFAULT_DB ") + *default_db + " not found.");
1167  }
1168  } else {
1169  db.dbId = -1;
1170  }
1171  if (db.dbId != user.defaultDbId) {
1172  return true;
1173  }
1174  }
1175  if (can_login && *can_login != user.can_login) {
1176  return true;
1177  }
1178  return false;
1179 }
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: