forked from Transparency/kgroad-frontend2
just started rewritig the project, found a lot of fails
This commit is contained in:
1 parent
eeb9cc7ff8
commit
60b136effd
277 files changed
+1833
-5415
No files matched your search
@@ -1,3 +1,7 @@
|
||||
import AboutUsPage from "@/Pages/AboutUsPage/AboutUsPage";
|
||||
import React from "react";
|
||||
|
||||
export default AboutUsPage;
|
||||
const page = () => {
|
||||
return <div>page</div>;
|
||||
};
|
||||
|
||||
export default page;
|
||||
@@ -1,91 +0,0 @@
|
||||
import axios from "axios";
|
||||
import NextAuth, { NextAuthOptions } from "next-auth";
|
||||
import { JWT } from "next-auth/jwt";
|
||||
import CredentialsProvider from "next-auth/providers/credentials";
|
||||
|
||||
interface IToken {
|
||||
access: string;
|
||||
}
|
||||
|
||||
const refreshToken = async (token: JWT): Promise<JWT> => {
|
||||
const data = {
|
||||
refresh: token.refresh_token,
|
||||
};
|
||||
|
||||
const response = await axios.post<IToken>(
|
||||
"https://api.kgroaduat.fishrungames.com/api/v1/token/refresh/",
|
||||
data
|
||||
);
|
||||
|
||||
return {
|
||||
...token,
|
||||
access_token: response.data.access,
|
||||
};
|
||||
};
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
name: "Credentials",
|
||||
credentials: {
|
||||
email: {
|
||||
label: "Email",
|
||||
type: "text",
|
||||
placeholder: "jsmith@example.com",
|
||||
},
|
||||
password: { label: "Password", type: "password" },
|
||||
},
|
||||
async authorize(credentials, req) {
|
||||
if (!credentials?.email || !credentials?.password)
|
||||
return null;
|
||||
const { email, password } = credentials as any;
|
||||
|
||||
const res = await fetch(
|
||||
"https://api.kgroaduat.fishrungames.com/api/v1/users/login/",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
password,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status === 401) {
|
||||
console.log(res.status);
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = await res.json();
|
||||
return user;
|
||||
},
|
||||
}),
|
||||
],
|
||||
pages: {
|
||||
signIn: "/sign-in",
|
||||
},
|
||||
session: {
|
||||
strategy: "jwt",
|
||||
},
|
||||
callbacks: {
|
||||
async jwt({ token, user }) {
|
||||
if (user) return { ...token, ...user };
|
||||
|
||||
return refreshToken(token);
|
||||
},
|
||||
|
||||
async session({ token, session }) {
|
||||
session.access_token = token.access_token;
|
||||
session.refresh_token = token.refresh_token;
|
||||
|
||||
return session;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const handler = NextAuth(authOptions);
|
||||
|
||||
export { handler as GET, handler as POST };
|
||||
@@ -1,3 +0,0 @@
|
||||
import CreateReportPage from "@/Pages/CreateReportPage/CreateReportPage";
|
||||
|
||||
export default CreateReportPage;
|
||||
@@ -1,7 +0,0 @@
|
||||
import React from "react";
|
||||
|
||||
const page = () => {
|
||||
return <div>page</div>;
|
||||
};
|
||||
|
||||
export default page;
|
||||
+1
-7
@@ -1,9 +1,3 @@
|
||||
import RootLayout from "@/App/App";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "KG Road",
|
||||
description: "Road in Kyrgyzstan",
|
||||
};
|
||||
import RootLayout from "@/app/App";
|
||||
|
||||
export default RootLayout;
|
||||
@@ -1,3 +0,0 @@
|
||||
import NewsDetailsPage from "@/Pages/NewsDetailsPage/NewsDetailsPage";
|
||||
|
||||
export default NewsDetailsPage;
|
||||
@@ -1,3 +0,0 @@
|
||||
import NewsPage from "@/Pages/NewsPage/NewsPage";
|
||||
|
||||
export default NewsPage;
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
import Homepage from "@/Pages/Homepage/Homepage";
|
||||
import Home from "@/pages/Home/Home";
|
||||
|
||||
export default Homepage;
|
||||
export default Home;
|
||||
@@ -1,3 +0,0 @@
|
||||
import ProfileLayout from "@/Pages/profile/ProfilePage/ProfileLayout";
|
||||
|
||||
export default ProfileLayout;
|
||||
@@ -1,3 +0,0 @@
|
||||
import MyReportsPage from "@/Pages/profile/MyReportsPage/MyReportsPage";
|
||||
|
||||
export default MyReportsPage;
|
||||
File renamed without changes.
@@ -1,3 +0,0 @@
|
||||
import PersonalDataPage from "@/Pages/profile/PersonalDataPage/PersonalDataPage";
|
||||
|
||||
export default PersonalDataPage;
|
||||
@@ -1,3 +0,0 @@
|
||||
import ReportDetailsPage from "@/Pages/ReportDetailsPage/ReportDetailsPage";
|
||||
|
||||
export default ReportDetailsPage;
|
||||
@@ -1,3 +1,7 @@
|
||||
import SignInPage from "@/Pages/SignInPage/SignInPage";
|
||||
import React from "react";
|
||||
|
||||
export default SignInPage;
|
||||
const page = () => {
|
||||
return <div>page</div>;
|
||||
};
|
||||
|
||||
export default page;
|
||||
@@ -1,3 +0,0 @@
|
||||
import SignUpPage from "@/Pages/SignUpPage/SignUpPage";
|
||||
|
||||
export default SignUpPage;
|
||||
@@ -1,3 +0,0 @@
|
||||
import StatisticsPage from "@/Pages/StatisticsPage/StatisticsPage";
|
||||
|
||||
export default StatisticsPage;
|
||||
@@ -1,3 +0,0 @@
|
||||
import VolunteersPage from "@/Pages/VolunteersPage/VolunteersPage";
|
||||
|
||||
export default VolunteersPage;
|
||||
Reference in new issue
Block a user