From 91b94a27d0be07c7f8c4e0a42999d1bcf382b0c4 Mon Sep 17 00:00:00 2001 From: Pablo George Date: Sun, 29 Sep 2024 11:59:04 -0300 Subject: [PATCH] adicionando o login via Github --- .env.example | 4 ++++ README.md | 5 ++++- app/auth/signin/page.tsx | 6 +++--- auth.ts | 3 ++- package.json | 1 + pnpm-lock.yaml | 12 ++++++++++++ 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c5ebf79 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +AUTH_SECRET="AUTH_SECRET_KEY" # Added by `npx auth`. Read more: https://cli.authjs.dev +AUTH_TRUST_HOST=true +AUTH_GITHUB_SECRET="GITHUB_SECRET_KEY" +AUTH_GITHUB_ID="GITHUB_ID" \ No newline at end of file diff --git a/README.md b/README.md index 6ac0cfe..9cb6cb8 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,7 @@ pnpm dlx shadcn@latest add card button form input 5 - Iniciando a configuração do Next-Auth ```bash pnpm dlx auth secret -``` \ No newline at end of file +``` +6 - Passo a passo para a configuração social do Github +6.1 acessar o endereço: `https://github.com/settings/apps` +selecionar a opção [OAuth Apps]->[New OAuth App] e seguir os passos necessários, lembrando que é necessário informar a Authorization callback no formato: `http://localhost:3000/api/auth/callback/github` \ No newline at end of file diff --git a/app/auth/signin/page.tsx b/app/auth/signin/page.tsx index 220fb33..c28b8df 100644 --- a/app/auth/signin/page.tsx +++ b/app/auth/signin/page.tsx @@ -11,7 +11,7 @@ import { } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; -//import { GitHubLogoIcon } from "@radix-ui/react-icons"; +import { GitHubLogoIcon } from "@radix-ui/react-icons"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -106,10 +106,10 @@ export default function SignIn() { or
- {/* */} +
diff --git a/auth.ts b/auth.ts index c0605ea..a239a09 100644 --- a/auth.ts +++ b/auth.ts @@ -1,10 +1,11 @@ import NextAuth from "next-auth"; import Credentials from "next-auth/providers/credentials"; -import async from "./app/page"; +import Github from "next-auth/providers/github"; import { signInSchema } from "./lib/zod"; export const { handlers, signIn, signOut, auth } = NextAuth({ providers: [ + Github, Credentials({ credentials: { email: { label: "Email", type: "email", placeholder: "seu@email.com" }, diff --git a/package.json b/package.json index 5365874..82f100a 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@hookform/resolvers": "^3.9.0", + "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-slot": "^1.1.0", "class-variance-authority": "^0.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43beb67..fa7a81e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@hookform/resolvers': specifier: ^3.9.0 version: 3.9.0(react-hook-form@7.53.0(react@18.3.1)) + '@radix-ui/react-icons': + specifier: ^1.3.0 + version: 1.3.0(react@18.3.1) '@radix-ui/react-label': specifier: ^2.1.0 version: 2.1.0(@types/react-dom@18.3.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -202,6 +205,11 @@ packages: '@types/react': optional: true + '@radix-ui/react-icons@1.3.0': + resolution: {integrity: sha512-jQxj/0LKgp+j9BiTXz3O3sgs26RNet2iLWmsPyRz2SIcR4q/4SbazXfnYwbAr+vLYKSfc7qxzyGQA1HLlYiuNw==} + peerDependencies: + react: ^16.x || ^17.x || ^18.x + '@radix-ui/react-label@2.1.0': resolution: {integrity: sha512-peLblDlFw/ngk3UWq0VnYaOLy6agTZZ+MUO/WhVfm14vJGML+xH4FAl2XQGLqdefjNb7ApRg6Yn7U42ZhmYXdw==} peerDependencies: @@ -887,6 +895,10 @@ snapshots: optionalDependencies: '@types/react': 18.3.10 + '@radix-ui/react-icons@1.3.0(react@18.3.1)': + dependencies: + react: 18.3.1 + '@radix-ui/react-label@2.1.0(@types/react-dom@18.3.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)