-
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.
commit f0d5514 Author: nasubi916 <[email protected]> Date: Sat Nov 9 22:44:29 2024 +0900 ok commit cf26f4b Author: nasubi916 <[email protected]> Date: Fri Nov 8 00:34:02 2024 +0900 スポンサーログイン commit 9af88a5 Author: nasubi916 <[email protected]> Date: Fri Nov 8 00:08:06 2024 +0900 年齢入力 commit 7bba08c Author: nasubi916 <[email protected]> Date: Thu Nov 7 23:04:23 2024 +0900 仮アカウントログインからgoogleに変更 commit dd23d39 Author: nasubi916 <[email protected]> Date: Tue Nov 5 23:05:48 2024 +0900 💄 ユーザー認証画面にアカウントタイプ選択ボタンを追加
- Loading branch information
1 parent
30d2e9e
commit 8dc2a90
Showing
2 changed files
with
72 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { type Session } from "@supabase/supabase-js"; | ||
import { type UseNavigateResult } from "@tanstack/react-router"; | ||
import { ResultAsync } from "neverthrow"; | ||
import { ok, ResultAsync } from "neverthrow"; | ||
import { match } from "ts-pattern"; | ||
import { Sower } from "./sower"; | ||
import { Sponsor } from "./sponsor"; | ||
|
@@ -36,9 +36,11 @@ export class User { | |
|
||
static async signIn(): Promise<void> { | ||
match( | ||
await supabase.auth.signInWithPassword({ | ||
email: "[email protected]", | ||
password: "password", | ||
await supabase.auth.signInWithOAuth({ | ||
provider: "google", | ||
options: { | ||
redirectTo: `${document.location.origin}/user/auth`, | ||
}, | ||
}), | ||
).with(S.Error, ({ error }) => { | ||
notifyErrorInToast("User.signIn", error, "サインインに失敗しました"); | ||
|
@@ -105,4 +107,33 @@ export class User { | |
Table.transformError(config, "fetchOwnComments", error), | ||
); | ||
} | ||
|
||
public fetchKindOf(): TableResult< | ||
| { | ||
type: "SOWER"; | ||
data: Sower; | ||
} | ||
| { | ||
type: "SPONSOR"; | ||
data: Sponsor; | ||
} | ||
| { | ||
type: "UNKNOWN"; | ||
} | ||
> { | ||
const data = ResultAsync.combine([ | ||
Sower.factories.fromUser(this.id).orElse(() => ok(null)), | ||
Sponsor.factories.fromUser(this.id).orElse(() => ok(null)), | ||
]); | ||
|
||
return data.andThen(([sower, sponsor]) => { | ||
if (sower != null) { | ||
return ok({ type: "SOWER", data: sower } as const); | ||
} | ||
if (sponsor != null) { | ||
return ok({ type: "SPONSOR", data: sponsor } as const); | ||
} | ||
return ok({ type: "UNKNOWN" } as const); | ||
}); | ||
} | ||
} |
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