80 lines
1.2 KiB
C++
Executable File
80 lines
1.2 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfile_winix_core_user
|
|
#define headerfile_winix_core_user
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
|
|
|
|
/*
|
|
a temporary struct used for hashing and encrypting a user's password
|
|
*/
|
|
struct UserPass
|
|
{
|
|
int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h)
|
|
std::wstring pass; // password hashed or plain text if pass_type==0
|
|
std::string pass_encrypted; // password encrypted
|
|
bool pass_hash_salted; // true when the hash was salted (plain text passwords are never salted)
|
|
};
|
|
|
|
|
|
|
|
struct User
|
|
{
|
|
long id;
|
|
std::wstring name;
|
|
bool super_user;
|
|
std::vector<long> groups;
|
|
std::wstring email;
|
|
int notify;
|
|
|
|
|
|
// !! currently all users have the same offset
|
|
// option in config: time_zone_offset
|
|
int time_zone_offset;
|
|
|
|
|
|
|
|
User()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
|
|
void Clear()
|
|
{
|
|
id = -1;
|
|
name.clear();
|
|
super_user = false;
|
|
groups.clear();
|
|
email.clear();
|
|
notify = 0;
|
|
time_zone_offset = 0;
|
|
}
|
|
|
|
|
|
bool IsMemberOf(long group)
|
|
{
|
|
std::vector<long>::iterator i;
|
|
|
|
for(i=groups.begin() ; i!=groups.end() ; ++i)
|
|
if( *i == group )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
#endif
|