2008-12-21 22:17:09 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-21 22:17:09 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2012-01-08 04:59:51 +01:00
|
|
|
* Copyright (c) 2008-2012, Tomasz Sowa
|
2008-12-21 22:17:09 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_user
|
|
|
|
#define headerfile_winix_core_user
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2012-05-01 00:53:54 +02:00
|
|
|
#include "space/space.h"
|
2012-05-24 23:09:37 +02:00
|
|
|
#include "date/date.h"
|
2008-12-21 22:17:09 +01:00
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2012-02-28 22:09:44 +01:00
|
|
|
#define WINIX_ACCOUNT_MAX_LOGIN_SIZE 250
|
|
|
|
#define WINIX_ACCOUNT_MAX_PASSWORD_SIZE 250
|
|
|
|
#define WINIX_ACCOUNT_MAX_EMAIL_SIZE 250
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// account status
|
|
|
|
// 1 - a user has created its account -- an email was sent back to him
|
|
|
|
#define WINIX_ACCOUNT_NOT_ACTIVATED 1
|
|
|
|
|
|
|
|
// 2 - a user clicked on the link in the mail and now can normally use his account
|
|
|
|
#define WINIX_ACCOUNT_READY 2
|
|
|
|
|
|
|
|
// 3 - account was suspended
|
|
|
|
#define WINIX_ACCOUNT_SUSPENDED 3
|
|
|
|
|
|
|
|
// 4 - account was banned
|
|
|
|
#define WINIX_ACCOUNT_BLOCKED 4
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
a user can login only to an account which status is equal to WINIX_ACCOUNT_READY
|
|
|
|
|
|
|
|
actually there is no difference between WINIX_ACCOUNT_SUSPENDED and WINIX_ACCOUNT_BANNED
|
|
|
|
only a different message will be present on the website
|
|
|
|
|
|
|
|
you can use other values of status in your plugins - this not have any impact on winix
|
|
|
|
the default 'login' winix function only allowes to login a user who has WINIX_ACCOUNT_READY value
|
|
|
|
but you can provide your own 'login' function which can work in a different way
|
|
|
|
|
|
|
|
winix knows that user is login when cur->session->puser pointer is set
|
|
|
|
(when the pointer is not null then winix do not check what the value of 'status' is --
|
|
|
|
the status is only tested in 'login' function)
|
|
|
|
*/
|
|
|
|
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
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)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
struct User
|
|
|
|
{
|
|
|
|
long id;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring name;
|
2008-12-21 22:17:09 +01:00
|
|
|
bool super_user;
|
|
|
|
std::vector<long> groups;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring email;
|
2010-12-06 01:25:46 +01:00
|
|
|
int notify;
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
|
2012-01-08 04:59:51 +01:00
|
|
|
// environment variables which can be set by this user
|
|
|
|
// use 'env' winix function
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space env;
|
2012-01-08 04:59:51 +01:00
|
|
|
|
|
|
|
// environment variables set only by an administrator
|
|
|
|
// an administrator can use 'env' winix function with 'a' parameter
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space aenv;
|
2012-01-08 04:59:51 +01:00
|
|
|
|
2012-02-28 22:09:44 +01:00
|
|
|
// account status
|
|
|
|
// WINIX_ACCOUNT_*
|
|
|
|
// a user can normally login only when status is WINIX_ACCOUNT_READY
|
|
|
|
int status;
|
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
// locale identifier
|
|
|
|
size_t locale_id;
|
|
|
|
|
|
|
|
// time zone identifier
|
|
|
|
size_t time_zone_id;
|
2012-05-24 23:09:37 +02:00
|
|
|
|
|
|
|
|
2012-05-30 21:04:18 +02:00
|
|
|
User();
|
2008-12-21 22:17:09 +01:00
|
|
|
|
2012-05-30 21:04:18 +02:00
|
|
|
void Clear();
|
|
|
|
bool IsMemberOf(long group);
|
|
|
|
bool ReadMonthDayTime(PT::Date & date, const wchar_t * str);
|
|
|
|
bool SetTzFromEnv();
|
2012-05-24 23:09:37 +02:00
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|