-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
認証されたユーザーを取得するクラス名を変更した。ユーザーをデータベースに登録するためのクラスを準備した。
- Loading branch information
1 parent
0229d4e
commit ed57403
Showing
31 changed files
with
299 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { createContext } from "react"; | ||
import FF14SnsUser from "../../models/user/ff14-sns-user"; | ||
import SnsUser from "../../models/user/sns-user"; | ||
|
||
/** | ||
* SNSのユーザーコンテキスト。 | ||
*/ | ||
export const SnsUserContext = createContext<FF14SnsUser | null>(null); | ||
export const SnsUserContext = createContext<SnsUser | null>(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import IUserRegistrar from './i-user-registrar'; | ||
import IUserRepository from '../../repositories/user/i-user-repository'; | ||
|
||
/** | ||
* ユーザーの登録を行うクラス。 | ||
*/ | ||
export default class UserRegistrar implements IUserRegistrar { | ||
/** | ||
* ユーザーの登録を行うクラスを生成する。 | ||
* @param userRepository ユーザーのリポジトリ。 | ||
*/ | ||
constructor( | ||
private readonly userRepository: IUserRepository, | ||
) { | ||
} | ||
|
||
register(userName: string): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
delete(id: string): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import AuthenticatedUser from "../../models/user/authenticated-user"; | ||
import IAuthenticatedUserProvider from "../../libraries/user/i-authenticated-user-provider"; | ||
|
||
/** | ||
* 認証済みユーザーを取得するローダー。 | ||
*/ | ||
export default class AuthenticatedUserLoader { | ||
/** | ||
* 認証済みユーザーを取得するローダーを生成する。 | ||
* @param authenticatedUserProvider 認証済みユーザーを提供するクラス。 | ||
*/ | ||
constructor( | ||
private readonly authenticatedUserProvider: IAuthenticatedUserProvider | ||
) { | ||
} | ||
|
||
/** | ||
* 認証済みユーザーを取得する。 | ||
* @param token トークン。 | ||
* @returns 認証済みユーザー。 | ||
*/ | ||
public async getUser(token: string): Promise<AuthenticatedUser> { | ||
const authenticatedUser = await this.authenticatedUserProvider.getUser(token); | ||
return authenticatedUser; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Entity from '../common/entity'; | ||
|
||
/** | ||
* 認証済みユーザー。 | ||
*/ | ||
export default interface AuthenticatedUser extends Entity { | ||
/** | ||
* プロフィールID。 | ||
*/ | ||
readonly profileId: string; | ||
|
||
/** | ||
* 認証プロバイダID。 | ||
*/ | ||
readonly authenticationProviderId: string; | ||
|
||
/** | ||
* ユーザー名。 | ||
*/ | ||
readonly userName: string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* SNSのユーザー。 | ||
*/ | ||
export default interface SnsUser { | ||
/** | ||
* ユーザー名。 | ||
*/ | ||
readonly userName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import User from '../../models/user/user'; | ||
import IUserRepository from './i-user-repository'; | ||
|
||
/** | ||
* Postgresのユーザーのリポジトリ。 | ||
*/ | ||
export default class PostgresUserRepository implements IUserRepository { | ||
create(): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
update(user: User): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
delete(id: string): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
findById(id: string): Promise<User | null> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
findByProfileId(profileId: string): Promise<User | null> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
findByAuthenticationProviderId(authenticationProviderId: string): Promise<User | null> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ActionFunctionArgs, json, redirect } from "@netlify/remix-runtime"; | ||
import { Form } from "@remix-run/react"; | ||
|
||
export const action = async ({ | ||
request, | ||
context, | ||
}: ActionFunctionArgs) => { | ||
// フォームデータを取得する。 | ||
const formData = await request.formData(); | ||
const userName = formData.get("userName") as string; | ||
|
||
// ユーザー名がない場合、エラーを返す。 | ||
if (!userName) return json({ error: "ユーザー名が入力されていません。" }); | ||
|
||
// ユーザーを登録する。 | ||
context.snsUserRegistrationAction.register(userName); | ||
return redirect("/app"); | ||
} | ||
|
||
/** | ||
* ユーザー登録ページ。 | ||
* @returns ユーザー登録ページ。 | ||
*/ | ||
export default function RegisterUser() { | ||
return ( | ||
<Form method="post"> | ||
<label htmlFor="userName">FF14のユーザー名(user_name@world)</label> | ||
<input type="text" name="userName" /> | ||
<button type="submit">登録</button> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.