Merge pull request #162 from nitta-lab-2024/fixBranch
fix
commit 23d726fe66d2f00164d8e1528511b5e9d7c5cba9
2 parents 7fa7d9c + 5888665
amika uemura authored on 23 May
Showing 4 changed files
View
10
src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java
}
 
// account_idとpasswordを設定し新しいアカウントを作成する(POST)
public String createAccount(String accountId, String password) {
UUID str = UUID.randomUUID();
String token = str.toString();
Account account = new Account(accountId, password);
if(!accounts.containsKey(accountId)) {
UUID str = UUID.randomUUID();
String token = str.toString();
Account account = new Account(accountId, password);
accounts.put(accountId, account);
accountToken.put(accountId, token); //accountIDとtokenをHashMapに入れる
return token;
} else {
return null;
}
return token;
}
 
//accountIdとtokenを比較してtrueかfalseを返す
public boolean checkToken(String accountId, String token) {
View
4
src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java
var response = Response.status(Response.Status.BAD_REQUEST).entity("passwordを入力してください");
throw new WebApplicationException(response.build());
}
token = accountManager.createAccount(accountId, password);
if (token == null){
var response = Response.status(Response.Status.CONFLICT).entity("id '" + accountId + "' は既に存在します");//404
throw new WebApplicationException(response.build());
}
return token;
}
 
// 指定されたアカウントの情報を返す(GET)
View
src/main/java/org/ntlab/citrusserver/resources/BooksRest.java
View
src/main/java/org/ntlab/citrusserver/resources/PublicBooksRest.java