Skip to content

Commit

Permalink
Merge pull request #194 from idurar/master
Browse files Browse the repository at this point in the history
auth bugs fixed
  • Loading branch information
salahlalami authored Jun 25, 2023
2 parents 0a4ae49 + 3a35c73 commit a367bcc
Show file tree
Hide file tree
Showing 233 changed files with 757 additions and 13,239 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/apptest.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/deploy.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/github-repo-stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: github-repo-stats

on:
schedule:
# Run this once per day, towards the end of the day for keeping the most
# recent data point most meaningful (hours are interpreted in UTC).
- cron: "50 23 * * *"
workflow_dispatch: # Allow for running this manually.

jobs:
j1:
name: github-repo-stats
runs-on: ubuntu-latest
steps:
- name: run-ghrs
# Use latest release.
uses: jgehrcke/github-repo-stats@RELEASE
with:
ghtoken: ${{ secrets.ghrs_github_api_token }}

File renamed without changes.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# IDURAR ERP/CRM Based Mern Stack and Ant Design (Express.js / React / Redux / MongoDB)
# ERP / CRM Open Source based on (Node.js/React.js)

IDURAR is Open Source ERP/CRM (Invoice / Inventory / Accounting / HR) Based on Advanced Mern Stack (Node.js / Express.js / MongoDb / React.js ) with Ant Design (AntD) and Redux

```
Don't forget please to ⭐ this repo if you like this Starter Antd Admin!
Can you star our Open Source ERP/CRM repo? 🤩 !
```

![screenshot-mern-redux-crud-app-idurar vercel app-2021 09 02-11_05_01](https://user-images.githubusercontent.com/50052356/141647096-dcb66696-6103-4850-ae21-9fc97a412252.png)
![screenshot-mern-redux-crud-app-idurar vercel app-2021 09 02-11_04_25](https://user-images.githubusercontent.com/50052356/141647100-9dfd6ee5-f873-42a8-8923-88bd0cf53606.png)
![Open Source ERP/CRM - MERN Stack (Node.js/React.js)](https://user-images.githubusercontent.com/50052356/141647096-dcb66696-6103-4850-ae21-9fc97a412252.png)
![Open Source ERP/CRM - MERN Stack (Node.js/React.js)](https://user-images.githubusercontent.com/50052356/141647100-9dfd6ee5-f873-42a8-8923-88bd0cf53606.png)

## CRM Starter Mern Antd Admin App
## Open Source ERP / CRM App

I build Starter Crm App based on mern stack (Express.js / MongoDb / React / Redux / AntD) with generic crud and auth , admin management .
IDURAR is Open Source ERP/CRM (Invoice / Inventory / Accounting / HR) Based on Mern Stack (Node.js / Express.js / MongoDb / React.js ) with Ant Design (AntD) and Redux

**Live App Demo** : [https://mern-redux-crud-app.vercel.app](https://mern-redux-crud-app.vercel.app) "Please use chrome"
**Live App Demo** : [https://idurarapp.com/open-source-erp-crm/](https://idurarapp.com/open-source-erp-crm/) "Please use chrome"

`username : admin@demo.com password : admin123`
2 changes: 0 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ app.use(
erpAuthRouter
);

// app.use("/api", cors(), isValidAdminToken, erpApiRouter);

app.use(
'/api',
cors({
Expand Down
53 changes: 32 additions & 21 deletions controllers/erpControllers/authJwtController .js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports.login = async (req, res) => {
id: admin._id,
},
process.env.JWT_SECRET,
{ expiresIn: '72h' }
{ expiresIn: req.body.remember ? 365 * 24 + 'h' : '24h' }
);

const result = await Admin.findOneAndUpdate(
Expand All @@ -53,25 +53,28 @@ exports.login = async (req, res) => {
}
).exec();

res.cookie('token', token, {
maxAge: req.body.remember ? 72 * 60 * 60 * 1000 : 60 * 60 * 1000, // Cookie expires after 30 days
sameSite: 'none',
httpOnly: true,
secure: true,
});

res.json({
success: true,
result: {
token,
admin: {
id: result._id,
name: result.name,
isLoggedIn: result.isLoggedIn,
res
.status(200)
.cookie('token', token, {
maxAge: req.body.remember ? 365 * 24 * 60 * 60 * 1000 : null, // Cookie expires after 30 days
sameSite: 'Lax',
httpOnly: true,
secure: process.env.NODE_ENV === 'production' ? true : false,
domain: req.hostname,
Path: '/',
})
.json({
success: true,
result: {
token,
admin: {
id: result._id,
name: result.name,
isLoggedIn: result.isLoggedIn,
},
},
},
message: 'Successfully login admin',
});
message: 'Successfully login admin',
});
} catch (err) {
res.status(500).json({ success: false, result: null, message: err.message, error: err });
}
Expand Down Expand Up @@ -138,6 +141,14 @@ exports.logout = async (req, res) => {
}
).exec();

res.clearCookie('token');
res.json({ isLoggedOut: true });
res
.clearCookie('token', {
maxAge: null, // Cookie expires after 30 days
sameSite: 'Lax',
httpOnly: true,
secure: process.env.NODE_ENV === 'production' ? true : false,
domain: req.hostname,
Path: '/',
})
.json({ isLoggedOut: true });
};
2 changes: 0 additions & 2 deletions controllers/erpControllers/settingCommercialController.js

This file was deleted.

2 changes: 0 additions & 2 deletions controllers/erpControllers/settingGlobalController.js

This file was deleted.

2 changes: 2 additions & 0 deletions controllers/erpControllers/settingsController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const crudController = require('../corsControllers/crudController');
module.exports = crudController.createCRUDController('Settings');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
]
},
"devDependencies": {
"@craco/craco": "6.4.3",
"@craco/craco": "5.5.0",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@testing-library/react-hooks": "7.0.2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export default function Navigation() {
Admin
</Menu.Item>
<SubMenu key={'Settings'} icon={<SettingOutlined />} title={'Settings'}>
<Menu.Item key={'SettingsPage'}>
<Link to={'/settings'} />
General Settings
</Menu.Item>
<Menu.Item key={'PaymentMode'}>
<Link to={'/payment/mode'} />
Payment Mode
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const API_BASE_URL =
process.env.NODE_ENV == 'production' || process.env.REACT_APP_DEV_REMOTE == 'remote'
? 'https://calm-ruby-barracuda-sock.cyclic.app/api/'
? 'https://erp-crm.idurarapp.com/api/'
: 'http://localhost:8888/api/';
export const DOWNLOAD_BASE_URL =
process.env.NODE_ENV == 'production' || process.env.REACT_APP_DEV_REMOTE == 'remote'
? 'https://calm-ruby-barracuda-sock.cyclic.app/download/'
? 'https://erp-crm.idurarapp.com/download/'
: 'http://localhost:8888/download/';
export const ACCESS_TOKEN_NAME = 'x-auth-token';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
71 changes: 71 additions & 0 deletions frontend/src/layout/SettingsLayout/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';

import { Layout } from 'antd';
import { Divider, Row, Col } from 'antd';

const { Content } = Layout;

const TopCard = ({ title, cardContent }) => {
return (
<div
className="whiteBox shadow"
style={{ color: '#595959', fontSize: 13, height: '106px', marginBottom: '24px' }}
>
<div className="pad15 strong" style={{ textAlign: 'center', justifyContent: 'center' }}>
<h3 style={{ color: '#22075e', marginBottom: 0 }}>{title}</h3>
</div>
<Divider style={{ padding: 0, margin: 0 }}></Divider>
<div className="pad15" style={{ textAlign: 'center', justifyContent: 'center' }}>
{cardContent}
</div>
</div>
);
};

export default function SettingsLayout({
children,
topCardTitle,
topCardContent,
bottomCardContent,
}) {
return (
<Layout className="site-layout">
<Content
style={{
padding: '30px 40px',
margin: '70px auto',
width: '100%',
maxWidth: '1100px',
}}
>
<Row gutter={[24, 24]}>
<Col
className="gutter-row"
xs={{ span: 24 }}
sm={{ span: 24 }}
md={{ span: 17 }}
lg={{ span: 18 }}
>
<div className="whiteBox shadow" style={{ minHeight: '480px' }}>
<Row className="pad10" gutter={[0, 0]}>
{children}
</Row>
</div>
</Col>
<Col
className="gutter-row"
xs={{ span: 24 }}
sm={{ span: 24 }}
md={{ span: 7 }}
lg={{ span: 6 }}
>
<TopCard title={topCardTitle} cardContent={topCardContent} />
<div className="whiteBox shadow" style={{ minHeight: '280px' }}>
<Row gutter={[0, 0]}>{bottomCardContent}</Row>
</div>
</Col>
</Row>
</Content>
</Layout>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as CrudLayout } from './CrudLayout';
export { default as ErpLayout } from './ErpLayout';
export { default as DefaultLayout } from './DefaultLayout';
export { default as DashboardLayout } from './DashboardLayout';
export { default as SettingsLayout } from './SettingsLayout';
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions frontend/src/pages/Settings/GeneralSettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Menu } from 'antd';

export default function GeneralSettings() {
return <p>General Settings here</p>;
}
5 changes: 5 additions & 0 deletions frontend/src/pages/Settings/InvoiceSettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Menu } from 'antd';

export default function InvoiceSettings() {
return <p>Invoice Settings here</p>;
}
5 changes: 5 additions & 0 deletions frontend/src/pages/Settings/PaymentSettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Menu } from 'antd';

export default function PaymentSettings() {
return <p>payment Settings here</p>;
}
62 changes: 62 additions & 0 deletions frontend/src/pages/Settings/Settings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useState, useEffect } from 'react';
import { Menu, Tabs, Button, Divider } from 'antd';
import { SettingsLayout } from '@/layout';

import GeneralSettings from './GeneralSettings';
import PaymentSettings from './PaymentSettings';
import InvoiceSettings from './InvoiceSettings';

const RightMenu = ({ activeTab, handleTabChange }) => {
const menuItems = [
{ key: 'generalSettings', label: 'generalSettings' },
{ key: 'paymentSettings', label: 'paymentSettings' },
{ key: 'invoiceSettings', label: 'invoiceSettings' },
];
const menuList = menuItems.map((item, index) => (
<Button
type={item.key == activeTab ? 'default' : 'text'}
key={item.key}
style={{ marginBottom: '10px' }}
block
onClick={() => handleTabChange(item.key)}
>
{item.label}
</Button>
));
return <div className="pad10">{menuList}</div>;
};

const Visibility = ({ isVisible = false, children }) => {
const show = isVisible ? { display: 'block', opacity: 1 } : { display: 'none', opacity: 0 };
return <div style={show}>{children}</div>;
};

export default function Settings() {
const [state, setState] = useState('generalSettings');

const isActive = (tab) => {
return state === tab ? true : false;
};

const handleTabChange = (tab) => {
setState(tab);
};

return (
<SettingsLayout
topCardContent="Generals Settings"
topCardTitle="Settings"
bottomCardContent={<RightMenu activeTab={state} handleTabChange={handleTabChange} />}
>
<Visibility isVisible={isActive('generalSettings')}>
<GeneralSettings />
</Visibility>
<Visibility isVisible={isActive('paymentSettings')}>
<PaymentSettings />
</Visibility>
<Visibility isVisible={isActive('invoiceSettings')}>
<InvoiceSettings />
</Visibility>
</SettingsLayout>
);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a367bcc

Please sign in to comment.