Skip to content

Commit

Permalink
Admin Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
MAMUNdevBD committed Jul 5, 2023
1 parent 05fe8f9 commit 336abfb
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 1,435 deletions.
7 changes: 7 additions & 0 deletions components/Layout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const DefaultLayout = ({ children }: PropsWithChildren) => {
const [animation, setAnimation] = useState(themeConfig.animation);
const dispatch = useDispatch();

const user = useSelector((state: any) => state.user?.user);
useEffect(() => {
if (!user || user.length == 0) {
router.push("/admin/login");
}
}, [router, user]);

const goToTop = () => {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
Expand Down
1 change: 0 additions & 1 deletion components/RecentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import RecentCard from "./RecentCard";

const RecentSection = () => {
const histories = useSelector((state: any) => state.history?.recentSurahs);
console.log("h", histories);

return (
<div className="container text-white py-5 px-5">
Expand Down
12 changes: 12 additions & 0 deletions controllers/AuthController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { db } from "@/database";

export class AuthController {
static login = async (data: { email: string; password: string }) => {
return await db("users")
.where({
mail: data.email,
password: data.password,
})
.first();
};
}
Loading

0 comments on commit 336abfb

Please sign in to comment.