diff --git a/src/main/java/org/ntlab/nemophila/models/accounts/AccountManager.java b/src/main/java/org/ntlab/nemophila/models/accounts/AccountManager.java index bf6cbfc..45b8dbc 100644 --- a/src/main/java/org/ntlab/nemophila/models/accounts/AccountManager.java +++ b/src/main/java/org/ntlab/nemophila/models/accounts/AccountManager.java @@ -11,31 +11,32 @@ private AccountManager() { } - + //シングルトン化 public static AccountManager getInstance() { if(theInstance == null){ theInstance = new AccountManager(); } return theInstance; } - + //アカウントの取得 public Account getAccount(String id){ return accountsMap.get(id); } - + //新規アカウントの作成 public Account createAccount(String name, String pw){ + //ランダムにトークンを作成 UUID uuid = UUID.randomUUID(); String token = (String) uuid.toString(); - Account ac = new Account(name, pw); ac.setToken(token); + //IDの作成 String id = Integer.toString(newId); ac.setId(id); newId++; accountsMap.put(id, ac); return ac; } - + //再ログイン時に新しいトークンを更新する public Account updateAccount(String id) { Account ac = accountsMap.get(id); UUID uuid = UUID.randomUUID(); @@ -43,4 +44,10 @@ ac.setToken(token); return ac; } + //アカウント消去 + public void deleteAccount(String id){ + accountsMap.remove(id); + } + + }