Добавление учетных записей администратором
This commit is contained in:
@@ -29,6 +29,7 @@ import org.apache.commons.lang.RandomStringUtils;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@@ -337,7 +338,7 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
account = new UserAccount(account_info);
|
||||
account.role = Constants.admins_mails.contains(account.email) ? AccountRole.Admin : AccountRole.User;
|
||||
credentials_db.Insert(account);
|
||||
FileUtils.writeStringToFile(account.getServerKeyFile(), RandomStringUtils.random(100, true, true));
|
||||
account.generateKey();
|
||||
}
|
||||
response.object = account;
|
||||
response.arg = FileUtils.readFileToString(account.getServerKeyFile());
|
||||
@@ -345,9 +346,18 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
void ReceiveCredentialsDatabase() throws Exception {
|
||||
response.object = Utils_.fileToBytes(credentials_db.getFile());
|
||||
}
|
||||
void PublishUserAccount() throws Exception {
|
||||
DBObject dbObject = (DBObject) request.object;
|
||||
response.object = (Serializable) credentials_db.InsertS(dbObject).getPK();
|
||||
//--
|
||||
credentials_db.userAccounts.get(response.object).generateKey();
|
||||
}
|
||||
void EditUserAccount() throws Exception {
|
||||
UserAccount new_object = (UserAccount) request.object;
|
||||
credentials_db.UpdateWithCheck(new_object);
|
||||
}
|
||||
void DeleteUserAccount() throws Exception {
|
||||
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
@@ -385,6 +395,9 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
@Override
|
||||
protected void Session() throws Exception {
|
||||
switch (code) {
|
||||
case PublishUserAccount:
|
||||
PublishUserAccount();
|
||||
break;
|
||||
case EditUserAccount:
|
||||
EditUserAccount();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user