| |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Collection<AccountJson> getAccounts(@QueryParam("name") String name) { |
---|
| | |
---|
| | var accountJsonList = new ArrayList<AccountJson>(); |
---|
| | |
---|
| | Consumer<Account> addJson = (account) -> { |
---|
| | { |
---|
| | var newAccountJson = new AccountJson(account); |
---|
| | accountJsonList.add(newAccountJson); |
---|
| |
---|
| | response = Response.status(404).entity("該当アカウントが存在しません。"); |
---|
| | throw new WebApplicationException(response.build()); |
---|
| | } |
---|
| | |
---|
| | // トークンの検証 |
---|
| | // トークンを検証し, 発見したユーザーを返却 |
---|
| | if (!token.equals(searchAccount.getToken())) response = Response.status(400).entity("トークンが違います。"); |
---|
| | else response.status(200).entity(searchAccount); |
---|
| | else return searchAccount; |
---|
| | |
---|
| | throw new WebApplicationException(response.build()); |
---|
| | } |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | // POST |
---|
| | //----------------------------------------------------------------- |
---|
| | // アカウントの新規作成 |
---|
| | // Uidを返却する |
---|
| | |
---|
| | /** |
---|
| | * @param name ユーザー名 |
---|
| | * @param email メアド |
---|
| |
---|
| | |
---|
| | ResponseBuilder response = Response.status(0); |
---|
| | |
---|
| | // パスワード, メアドが正しく入力されているかチェック |
---|
| | if (!isCorrectName(name) || !isCorrectPassword(password) || !isCorrectEmailAddress(email)) { |
---|
| | if (!isCorrectName(name) || !isCorrectPassword(password) || !isCorrectEmailAddress(email)) |
---|
| | response.status(401).entity("入力に誤りがあります。"); |
---|
| | throw new WebApplicationException(response.build()); |
---|
| | } |
---|
| | |
---|
| | // すでに同じメールアドレスが存在しているか |
---|
| | var existAccount = accounts.getAccountByEmail(email); |
---|
| | if (existAccount != null) response.status(400).entity("入力されたメールアドレスは既に使われています。"); |
---|
| | else { |
---|
| | // アカウント登録 |
---|
| | // アカウント登録をしてuidを返す |
---|
| | var newAccount = accounts.registerAccount(name, email, password); |
---|
| | response.status(200).entity(newAccount.getUid()); |
---|
| | return newAccount.getUid(); |
---|
| | } |
---|
| | |
---|
| | throw new WebApplicationException(response.build()); |
---|
| | } |
---|
| |
---|
| | |
確認お願いします.
[fix]AccountsRest/LoginRestの例外処理をreturnに修正
12f98c3
intomaster
fromfix/uid_bug_fix
on 25 May 2021