упразднение старого объекта аккаунта
This commit is contained in:
23
src/_VisualDVM/ComponentsServer/UserAccount/AccountRole.java
Normal file
23
src/_VisualDVM/ComponentsServer/UserAccount/AccountRole.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount;
|
||||
import java.io.Serializable;
|
||||
public enum AccountRole implements Serializable {
|
||||
Undefined,
|
||||
User,
|
||||
Developer,
|
||||
Admin;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Undefined:
|
||||
return "не зарегистрирован";
|
||||
case User:
|
||||
return "Пользователь";
|
||||
case Developer:
|
||||
return "Разработчик";
|
||||
case Admin:
|
||||
return "Администратор";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import Common.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
public class UserAccountDialog extends DBObjectDialog<UserAccount, UserAccountFields> {
|
||||
public UserAccountDialog() {
|
||||
super(UserAccountFields.class);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.ComponentsServer.BugReport.BugReport;
|
||||
import _VisualDVM.Global;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
public class UserAccount extends iDBObject {
|
||||
public String name = "";
|
||||
@@ -31,4 +33,55 @@ public class UserAccount extends iDBObject {
|
||||
name = name_in;
|
||||
email=email_in;
|
||||
}
|
||||
//todo часть устарело.разобрать.
|
||||
public boolean CheckRegistered(TextLog Log) {
|
||||
if (role.equals(AccountRole.Undefined)) {
|
||||
if (Log != null) {
|
||||
Log.Writeln("Пользователь не зарегистрирован");
|
||||
if (Global.mainModule.getUI().hasMainWindow())
|
||||
Global.mainModule.getUI().getMainWindow().FocusCallback();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isRegistered() {
|
||||
return !role.equals(AccountRole.Undefined);
|
||||
}
|
||||
public boolean CheckAuthorship(String address_in, TextLog log) {
|
||||
if (!isAdmin() && (!email.equals(address_in))) {
|
||||
if (log != null)
|
||||
log.Writeln_("Вы не являетесь автором или администратором");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean CheckAccessRights(String address_in, TextLog log) {
|
||||
return (CheckRegistered(log) && CheckAuthorship(address_in, log));
|
||||
}
|
||||
public boolean ExtendedCheckAccessRights(BugReport bugReport, TextLog log) {
|
||||
if (CheckRegistered(log)) {
|
||||
if (email.equals(bugReport.executor_address)) {
|
||||
//метод вывести как нерабочий.когда будет изменена схема админства.
|
||||
return true;
|
||||
} else {
|
||||
if (!isAdmin() && (!email.equals(bugReport.sender_address))) {
|
||||
log.Writeln_("Вы не являетесь автором, исполнителем, или администратором");
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isAdmin() {
|
||||
return role.equals(AccountRole.Admin);
|
||||
}
|
||||
public boolean CheckAdmin(TextLog log) {
|
||||
if (!isAdmin()) {
|
||||
log.Writeln_("Вы не являетесь администратором!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//---
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user