упразднение старого объекта аккаунта
This commit is contained in:
@@ -3,15 +3,14 @@ import Common.Utils.Utils_;
|
||||
import Common.Visual.UI;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import _VisualDVM.Passes.Server.ComponentsServerPass;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
public class CheckAccount extends ComponentsServerPass<UserAccount> {
|
||||
public class CheckAccount extends ComponentsServerPass {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Registry.png";
|
||||
@@ -23,22 +22,18 @@ public class CheckAccount extends ComponentsServerPass<UserAccount> {
|
||||
File keyFile;
|
||||
void confirmEmail() throws Exception{
|
||||
ConfirmEmail confirmEmailPass = (ConfirmEmail) Global.mainModule.getPass(PassCode.ConfirmEmail);;
|
||||
if (confirmEmailPass.Do(
|
||||
new UserAccount(Global.normalProperties.Name, Global.normalProperties.Email))
|
||||
) {
|
||||
UserAccount userAccount = confirmEmailPass.target;
|
||||
if (confirmEmailPass.Do(Global.mainModule.getAccount())) {
|
||||
//подтвердили почту. теперь проверяем ее роль на сервере. если на сервере нет акка будет создан
|
||||
if (SendRequest(ServerCode.GetUserAccountByEmail, "",userAccount)){
|
||||
target = (UserAccount) request.server_response.object;
|
||||
FileUtils.writeStringToFile(keyFile, target.security_key);
|
||||
if (SendRequest(ServerCode.GetUserAccountByEmail, "",Global.mainModule.getAccount())){
|
||||
Global.mainModule.setAccount((UserAccount) request.server_response.object);
|
||||
FileUtils.writeStringToFile(keyFile, Global.mainModule.getAccount().security_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target =null;
|
||||
Global.mainModule.getAccount().role = AccountRole.Undefined;
|
||||
keyFile = new File(Global.KeyDirectory, "key");
|
||||
Global.normalProperties.Role = AccountRole.Undefined;
|
||||
Global.normalProperties.Update();
|
||||
//--
|
||||
//1. Ищем ключ.
|
||||
@@ -50,7 +45,7 @@ public class CheckAccount extends ComponentsServerPass<UserAccount> {
|
||||
if (request.server_response.object!=null){
|
||||
//ключ актуальный.
|
||||
System.out.println("ключ совпал");
|
||||
target = (UserAccount) request.server_response.object;
|
||||
Global.mainModule.setAccount((UserAccount) request.server_response.object);
|
||||
}else {
|
||||
System.out.println("ключ не совпал!");
|
||||
//ключ неактуальный. регистрируемся по новой.
|
||||
@@ -63,11 +58,11 @@ public class CheckAccount extends ComponentsServerPass<UserAccount> {
|
||||
System.out.println("ключ не найден!");
|
||||
confirmEmail();
|
||||
}
|
||||
return target!=null;
|
||||
return !Global.mainModule.getAccount().role.equals(AccountRole.Undefined);
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
Global.normalProperties.SynchronizeAccount(target);
|
||||
Global.normalProperties.SynchronizeAccount(Global.mainModule.getAccount());
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user