|
Last change
on this file since e4c61dd was 505f39a, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added OAuth/prototype
|
-
Property mode
set to
100644
|
|
File size:
1011 bytes
|
| Line | |
|---|
| 1 | import React from "react";
|
|---|
| 2 | import { GoogleLogin } from "@react-oauth/google";
|
|---|
| 3 |
|
|---|
| 4 | export default function Login({ onDone }) {
|
|---|
| 5 | return (
|
|---|
| 6 | <div style={{ display: "grid", placeItems: "center", minHeight: "100vh" }}>
|
|---|
| 7 | <div className="panel" style={{ maxWidth: 460, width: "92%" }}>
|
|---|
| 8 | <div className="panel-head">
|
|---|
| 9 | <div className="panel-title">Sign in to netIntel</div>
|
|---|
| 10 | </div>
|
|---|
| 11 | <div className="panel-body">
|
|---|
| 12 | <GoogleLogin
|
|---|
| 13 | onSuccess={async (cred) => {
|
|---|
| 14 | const r = await fetch("/api/auth/google", {
|
|---|
| 15 | method: "POST",
|
|---|
| 16 | headers: { "Content-Type": "application/json" },
|
|---|
| 17 | credentials: "include",
|
|---|
| 18 | body: JSON.stringify({ credential: cred.credential }),
|
|---|
| 19 | });
|
|---|
| 20 | if (r.ok) onDone?.();
|
|---|
| 21 | else console.error(await r.json());
|
|---|
| 22 | }}
|
|---|
| 23 | onError={() => console.error("Google login failed")}
|
|---|
| 24 | />
|
|---|
| 25 | </div>
|
|---|
| 26 | </div>
|
|---|
| 27 | </div>
|
|---|
| 28 | );
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.