Skip to content

Commit

Permalink
feat: login as guest
Browse files Browse the repository at this point in the history
  • Loading branch information
gllm-dev committed Dec 18, 2024
1 parent 2008b36 commit 0f1dc08
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/apps/auth-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@heroicons/react": "^2.0.13",
"@openfort/openfort-js": "^0.8.13",
"@openfort/openfort-js": "^0.8.14",
"@openfort/openfort-node": "^0.6.65",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
40 changes: 36 additions & 4 deletions examples/apps/auth-sample/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ function LoginPage() {
if (user) loadData();
}, [user]);

const handleGuest = async (event: React.FormEvent<HTMLFormElement>) => {
setStatus({
type: "loading",
title: "Signing in...",
});
event.preventDefault();
const data = await openfort
.registerGuest()
.catch((error) => {
setStatus({
type: "error",
title: "Error signing in",
});
});
if (data) {
setStatus({
type: "success",
title: "Successfully signed in",
});
router.push("/");
}
}

const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
setStatus({
type: "loading",
Expand Down Expand Up @@ -162,13 +185,22 @@ function LoginPage() {
)}
</Button>
</form>
<div className="mt-6">
<Button
onClick={handleGuest}
variant="outline"
className="w-full"
>
<span>Continue as Guest</span>
</Button>
</div>
<div className="mt-6">
<div className="relative">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-gray-300" />
</div>
<div className="relative flex justify-center text-sm">
<span className="bg-white px-2 text-gray-500">
<span className="bg-white px-2 text-gray-500 b">
Or continue with
</span>
</div>
Expand All @@ -178,7 +210,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.GOOGLE,
options: {
redirectTo: getURL() + "/login",
Expand All @@ -195,7 +227,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.TWITTER,
options: {
redirectTo: getURL() + "/login",
Expand All @@ -212,7 +244,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.FACEBOOK,
options: {
redirectTo: getURL() + "/login",
Expand Down
10 changes: 5 additions & 5 deletions examples/apps/auth-sample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,9 @@ __metadata:
languageName: node
linkType: hard

"@openfort/openfort-js@npm:^0.8.13":
version: 0.8.13
resolution: "@openfort/openfort-js@npm:0.8.13"
"@openfort/openfort-js@npm:^0.8.14":
version: 0.8.14
resolution: "@openfort/openfort-js@npm:0.8.14"
dependencies:
"@ethersproject/abstract-signer": ^5.7.0
"@ethersproject/bytes": ^5.7.0
Expand All @@ -987,7 +987,7 @@ __metadata:
path: ^0.12.7
stream-browserify: ^3.0.0
uuid: ^8.3.2
checksum: 9e76e6437705537e9607492098ab0f98c8f70f4dc62669993abccc65b1d00916b2270c407941c4d32b82d2b81721daa7496a8c16a987d02cd6e0daa209738176
checksum: d15fe065492d0e9ae6c1e4aa5a36a6f581a2e6757711ae353b6e7e885bcc60576e3299b59ca5e82a5fd48505042549dca705d98e13e40896e33a10fa8d94201d
languageName: node
linkType: hard

Expand Down Expand Up @@ -2764,7 +2764,7 @@ __metadata:
resolution: "auth-sample@workspace:."
dependencies:
"@heroicons/react": ^2.0.13
"@openfort/openfort-js": ^0.8.13
"@openfort/openfort-js": ^0.8.14
"@openfort/openfort-node": ^0.6.65
"@radix-ui/react-dialog": ^1.1.2
"@radix-ui/react-icons": ^1.3.0
Expand Down

0 comments on commit 0f1dc08

Please sign in to comment.