OmniSciDB  4201147b46
 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 115 of file SysCatalog.h.

Member Function Documentation

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

Definition at line 1048 of file SysCatalog.cpp.

References can_login, default_db, is_super, and passwd.

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

1048  {
1049  std::stringstream ss;
1050  if (passwd) {
1051  if (hide_password) {
1052  ss << "PASSWORD='XXXXXXXX'";
1053  } else {
1054  ss << "PASSWORD='" << *passwd << "'";
1055  }
1056  }
1057  if (is_super) {
1058  if (!ss.str().empty()) {
1059  ss << ", ";
1060  }
1061  ss << "IS_SUPER='" << (*is_super ? "TRUE" : "FALSE") << "'";
1062  }
1063  if (default_db) {
1064  if (!ss.str().empty()) {
1065  ss << ", ";
1066  }
1067  ss << "DEFAULT_DB='" << *default_db << "'";
1068  }
1069  if (can_login) {
1070  if (!ss.str().empty()) {
1071  ss << ", ";
1072  }
1073  ss << "CAN_LOGIN='" << *can_login << "'";
1074  }
1075  return ss.str();
1076 }
std::optional< std::string > passwd
Definition: SysCatalog.h:116
std::optional< std::string > default_db
Definition: SysCatalog.h:118
std::optional< bool > is_super
Definition: SysCatalog.h:117
std::optional< bool > can_login
Definition: SysCatalog.h:119

+ Here is the caller graph for this function:

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

Definition at line 1022 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().

1022  {
1023  if (passwd && hash_with_bcrypt(*passwd) != user.passwd_hash) {
1024  return true;
1025  }
1026  if (is_super && *is_super != user.isSuper) {
1027  return true;
1028  }
1029  if (default_db) {
1030  DBMetadata db;
1031  if (!default_db->empty()) {
1033  throw std::runtime_error(string("DEFAULT_DB ") + *default_db + " not found.");
1034  }
1035  } else {
1036  db.dbId = -1;
1037  }
1038  if (db.dbId != user.defaultDbId) {
1039  return true;
1040  }
1041  }
1042  if (can_login && *can_login != user.can_login) {
1043  return true;
1044  }
1045  return false;
1046 }
std::optional< std::string > passwd
Definition: SysCatalog.h:116
std::optional< std::string > default_db
Definition: SysCatalog.h:118
std::optional< bool > is_super
Definition: SysCatalog.h:117
static SysCatalog & instance()
Definition: SysCatalog.h:336
std::string hash_with_bcrypt(const std::string &pwd)
Definition: SysCatalog.cpp:71
std::optional< bool > can_login
Definition: SysCatalog.h:119
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: