Skip to content

Commit

Permalink
config auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnhan90 committed Jan 13, 2024
1 parent f7695e7 commit 8f79b8e
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
NEXT_PUBLIC_ANALYTICS_ID=UA-114361661-6
BASE_URL=http://localhost:3001/
NO_SECRET=justaRandomstring
GITHUB_ID=
GITHUB_SECRET=

ALLOWED_METHODS="GET, POST, PUT, DELETE, OPTIONS"
ALLOWED_ORIGIN="*"
ALLOWED_HEADERS="Content-Type, Authorization"
DOMAIN_URL="http://localhost:3000"
DOMAIN_URL="http://localhost:3000"
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
NEXT_PUBLIC_ANALYTICS_ID=UA-114361661-6
BASE_URL=http://localhost:3001/
BASE_URL=http://localhost:3001/
NO_SECRET=justaRandomstring


ALLOWED_METHODS="GET, POST, PUT, DELETE, OPTIONS"
ALLOWED_ORIGIN="*"
ALLOWED_HEADERS="Content-Type, Authorization"
DOMAIN_URL="http://localhost:3000"
4 changes: 2 additions & 2 deletions public/images/frame-2729.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/app/api/auth/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import NextAuth from "next-auth/next";
import nextAuth, { AuthOptions } from "next-auth";
import Credentials from "next-auth/providers/credentials";

export const authOptions : AuthOptions = {
secret: process.env.NO_SECRET,
providers: []
}

const handler = nextAuth
14 changes: 2 additions & 12 deletions src/app/homepage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const HomePage = () =>{
</div>
<div className="pagination d-flex justify-content-end align-items-center">
<div className="carousel-arrow">
<img className="search-md-icon" alt="" src="./public/chevronleft.svg"
<img className="search-md-icon" alt="" src="/images/chevronleft.svg"
/>
</div>
<div className="pagination-dot-group">
Expand All @@ -54,7 +54,7 @@ const HomePage = () =>{
<div className="pagination-dot-indicator"></div>
</div>
<div className="carousel-arrow">
<img className="search-md-icon" alt="" src="./public/chevronright.svg" />
<img className="search-md-icon" alt="" src="/images/chevronright.svg" />
</div>

<b className="get-all-button">Xem tất cả</b>
Expand Down Expand Up @@ -111,19 +111,9 @@ const HomePage = () =>{
>
</div>
<div className="discount-up-to-wrapper d-flex align-items-center gap-1">
<img className=""
alt=""
src="/images/frame-2729.svg"
/>

<div className="discount-up-to">Ưu đãi đến 50k</div>
</div>
<div className="flavor-time-wrapper d-flex align-items-center gap-1">
<img className=""
alt=""
src="/images/frame-2725.svg"
/>

<div className="flavor-time">
Đặt trước 09:00 giờ sáng để điều chỉnh vị
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import '@/styles/order.css'
import '@/styles/login.css'
import '@/styles/style.css'

import { SessionProvider } from 'next-auth/react';
import NextAuthWrapper from '@/lib/next.auth.provider';
import Head from "next/head"

export default function RootLayout({children,}: {children: React.ReactNode;}) {
Expand All @@ -16,9 +18,9 @@ export default function RootLayout({children,}: {children: React.ReactNode;}) {
</Head>
<body>
{/* <ProgressBar /> */}

{children}

<NextAuthWrapper>
{children}
</NextAuthWrapper>
</body>
</html>
)
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/header/header1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Header1 = ({ isErrorPage }: HeaderType) => {
<div className="language-text">VIE</div>
<img className="small-icon"
alt=""
src="./public/vn.svg"
src="/images/vn.svg"
/>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/app/ui/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { useState } from 'react';
import CartHeader from "./cartHeader";
import CheckLogin from "./checkLogin";
import CartModel from "../cart/cartModel";
import { signIn, signOut, useSession } from 'next-auth/react';
type HeaderType = {
isErrorPage?: Boolean;
}

const Header = ({ isErrorPage }: HeaderType) => {
const [show, setShow] = useState(false);
const { data: session, status } = useSession();
console.log("sesstion ", session);
return(
<section className={`header-section d-flex justify-content-center `}>
<div className="header-container container w-100 d-flex justify-content-between align-items-center gap-5">
Expand Down
2 changes: 1 addition & 1 deletion src/components/homePage/interesting_food.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const InterestingFood = async () => {
<div className="discount-up-to-wrapper d-flex align-items-center gap-1">
<img className="small-icon"
alt=""
src="/imagesc/frame-2729.svg"
src="/images/frame-2729.svg"
/>

<div className="discount-up-to">Ưu đãi đến 50k</div>
Expand Down
11 changes: 11 additions & 0 deletions src/lib/next.auth.provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client'

import { SessionProvider } from 'next-auth/react';

export default function NextAuthWrapper({children,}: {children: React.ReactNode;}) {
return (
<SessionProvider>
{children}
</SessionProvider>
)
}

0 comments on commit 8f79b8e

Please sign in to comment.