Commit dc49d4c6 authored by fred's avatar fred
Browse files

generate ftp directory for each user

parent beccb4df
......@@ -140,7 +140,7 @@ void OnClientEvent( int Event, CFtpServer::CClientEntry *pClient, void *pArg )
}
bool Nodeftp::ncs_auth(QString email, QString &token)
bool Nodeftp::ncs_auth(QString email, QString &token, QString &directory)
{
/* QCryptographicHash cipher( QCryptographicHash::Sha1 );
cipher.addData(password.simplified().toAscii());
......@@ -159,6 +159,7 @@ bool Nodeftp::ncs_auth(QString email, QString &token)
return false;
}
token = QString::fromStdString(l_user.getFieldDotted("ftp.token").str());
directory = QString::fromStdString(l_user.getFieldDotted("ftp.directory").str());
return true;
}
......@@ -192,11 +193,11 @@ void Nodeftp::add_ftp_user(QString email)
{
qDebug() << "Nodeftp::add_user : " << email;
// check auth
QString token;
if (ncs_auth(email, token))
QString token, directory;
if (ncs_auth(email, token, directory))
{
// create user's directory
QString userdirectory = m_directory + "/ftp/" + email;
QString userdirectory = m_directory + "/ftp/" + directory;
if (!QDir(userdirectory).exists()) QDir().mkdir(userdirectory);
......
......@@ -35,7 +35,7 @@ public:
~Nodeftp();
private:
bool ncs_auth(QString login, QString &token);
bool ncs_auth(QString login, QString &token, QString &directory);
QString m_directory;
int m_port;
......
No preview for this file type
docs/ncs_dev.png

193 KB | W: | H:

docs/ncs_dev.png

451 KB | W: | H:

docs/ncs_dev.png
docs/ncs_dev.png
docs/ncs_dev.png
docs/ncs_dev.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -853,6 +853,10 @@ void Http_admin::admin_user_post(QxtWebRequestEvent* event)
QUuid ftp_token = QUuid::createUuid();
QString str_ftp_token = ftp_token.toString().remove(QChar('-')).mid(1,32);
QUuid ftp_directory = QUuid::createUuid();
QString str_ftp_directory = ftp_directory.toString().remove(QChar('-')).mid(1,32);
QUuid xmpp_token = QUuid::createUuid();
QString str_xmpp_token = xmpp_token.toString().remove(QChar('-')).mid(1,32);
......@@ -870,7 +874,7 @@ void Http_admin::admin_user_post(QxtWebRequestEvent* event)
"password" << QString::fromLatin1(password_hash.toHex()).toStdString() <<
"email" << form_field["email"].toStdString() <<
"token" << str_token.toStdString() <<
"ftp" << BSON ("token" << str_ftp_token.toStdString() << "activated" << ftp << "directory" << "default") <<
"ftp" << BSON ("token" << str_ftp_token.toStdString() << "activated" << ftp << "directory" << str_ftp_directory.toStdString()) <<
"tracker" << BSON ("token" << str_tracker_token.toStdString()) << "activated" << bittorrent <<
"xmpp" << BSON ("token" << str_xmpp_token.toStdString()) << "activated" << xmpp <<
"api" << BSON ("token" << str_api_token.toStdString()) << "activated" << api);
......
......@@ -89,7 +89,7 @@ private:
QBool http_auth(QString auth, QHash <QString, QString> &hauth, QString &str_session_uuid);
signals:
void create_workers_user(QString email);
void create_api_user(QString email);
void create_ftp_user(QString email);
void create_xmpp_user(QString email);
void create_bittorrent_user(QString email);
......
......@@ -439,6 +439,11 @@ void Http_api::user(QxtWebRequestEvent* event)
QUuid ftp_token = QUuid::createUuid();
QString str_ftp_token = ftp_token.toString().remove(QChar('-')).mid(1,32);
QUuid ftp_directory = QUuid::createUuid();
QString str_ftp_directory = ftp_directory.toString().remove(QChar('-')).mid(1,32);
QUuid xmpp_token = QUuid::createUuid();
QString str_xmpp_token = xmpp_token.toString().remove(QChar('-')).mid(1,32);
......@@ -467,13 +472,19 @@ void Http_api::user(QxtWebRequestEvent* event)
user_builder.append("password", QString::fromLatin1(password_hash.toHex()).toStdString());
user_builder.append("token", str_token.toStdString());
user_builder.append("ftp", BSON("token" << str_ftp_token.toStdString() << "activated" << ftp << "directory" << "default"));
user_builder.append("ftp", BSON("token" << str_ftp_token.toStdString() << "activated" << ftp << "directory" << str_ftp_directory.toStdString()));
user_builder.append("tracker" , BSON("token" << str_tracker_token.toStdString() << "activated" << tracker));
user_builder.append("xmpp" , BSON("token" << str_xmpp_token.toStdString() << "activated" << xmpp));
user_builder.append("api" , BSON("token" << str_api_token.toStdString() << "activated" << api));
BSONObj l_user = user_builder.obj();
mongodb_->Insert("users", l_user);
if (ftp) {
emit create_ftp_user(QString::fromStdString(b_user.getField("email").str()));
qDebug() << "EMIT CREATE FTP USER";
}
bodyMessage = buildResponse("token", str_token);
}
catch (mongo::MsgAssertionException &e)
......
......@@ -78,6 +78,12 @@ private:
Mongodb *mongodb_;
Zeromq *zeromq_;
signals:
void create_api_user(QString l_email);
void create_ftp_user(QString l_email);
void create_xmpp_user(QString l_email);
void create_bittorrent_user(QString l_email);
};
......
......@@ -150,4 +150,5 @@ void Service::Worker_init()
void Service::link()
{
if (m_nodeftp) connect(m_http_admin, SIGNAL(create_ftp_user(QString)), m_nodeftp, SLOT(add_ftp_user(QString)), Qt::DirectConnection);
if (m_nodeftp) connect(m_http_api, SIGNAL(create_ftp_user(QString)), m_nodeftp, SLOT(add_ftp_user(QString)), Qt::DirectConnection);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment