0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Authentication

Last updated at Posted at 2024-11-28

Previous << SDK Reference
Next >> How to Configure FCL

FCLにおける認証の概念は、FCLのcurrentUserの概念と密接に関係しています。実際、fcl.authenticateおよびfcl.unauthenticateはそれぞれfcl.currentUser.authenticate()およびfcl.currentUser.unauthenticate()のエイリアスです。ですのでこれからcurrentUserを見ていきましょう。

dapp開発者として私たちは、FCLを使用して、現時点で主な3つの機能を実現させる方法を考えます。

  • currentUser及び、それがログインしているかどうかを知る方法
  • ユーザーをログインさせる方法
  • ユーザーをログアウトさせる方法

FCLの仕組み上では、ユーザーのログインとユーザーのサインアップ(登録)は同じことです。

Knowing things about the current user

FCLは、現在のユーザー情報を取得する2つの方法を提供しています。1つは、その情報のsnapshotを返すpromiseです。もう1つは、あなたがsubscribeすることで、最新情報に変更が発生するたびに、コールバック関数を呼び出すことができる方法です。

Snapshot of Current User

import * as fcl from "@onflow/fcl"

const currentUser = await fcl.currentUser.snapshot()
console.log("The Current User", currentUser)

Subscribe to Current User

import * as fcl from "@onflow/fcl"

/* Returns an unsubscribe function */
const unsubscribe = fcl.currentUser.subscribe(currentUser => {
  console.log("The Current User", currentUser)
})

実際に Authenticating と Unauthenticating を行うには

結論から言うと、fcl.authenticate()fcl.unauthenticate() をそれぞれ呼び出すことです。

Flowのメインネット上で、この機能を使用するために何かを設定する必要は何もなく、それでありながら、あなたのdappユーザーは、認証プロセスを行っていき、FCL対応のウォレットプロバイダーを使用できるようになります。

開発の最中にはおそらく、あなたは@onflow/dev-walletを使用するために、あなたのdappを設定したくなるしょう。クイックスタートガイドはそれを使って説明してくれます。

これらすべてがかなり複雑に思うかもしれませんが、私たちは全力でサポートできます。何か問題に出くわした時は、Discordでご連絡ください。喜んでお手伝いいたしますので。

Last updated on Nov 20, 2024 by Chase Fleming

翻訳元


Previous << SDK Reference

Flow BlockchainのCadence version1.0ドキュメント (Authentication)

Next >> How to Configure FCL

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?