diff --git a/config/_development.json b/config/_development.json
index edb273e..eb77e8c 100644
--- a/config/_development.json
+++ b/config/_development.json
@@ -44,5 +44,12 @@
"enabled": true,
"origins": [ "http://eduardo-velasques.dev.netuno.org:10030", "http://localhost:3000", "http://127.0.0.1:3000" ]
}
- ]
+ ],
+ "jwt": {
+ "enabled": true,
+ "secret": "@X{DC5#9cuM#qG?d",
+ "access_expires": 60,
+ "refresh_expires": 1440,
+ "algorithm": "HS512"
+ }
}
diff --git a/dbs/social_ma.mv.db b/dbs/social_ma.mv.db
index afb04b2..f2892ea 100644
Binary files a/dbs/social_ma.mv.db and b/dbs/social_ma.mv.db differ
diff --git a/website/package.json b/website/package.json
index 7e5c2de..2a29958 100644
--- a/website/package.json
+++ b/website/package.json
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
+ "@netuno/auth-client": "^1.0.3",
"@netuno/service-client": "^1.0.7",
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
diff --git a/website/src/App.js b/website/src/App.js
index 2d3700d..c3c5a22 100644
--- a/website/src/App.js
+++ b/website/src/App.js
@@ -12,6 +12,7 @@ import {
import Home from './pages/Home';
import Login from './pages/Login';
import Register from './pages/Register';
+import Main from './pages/Main';
import logo from './logo.svg';
import './App.less';
@@ -60,6 +61,9 @@ function App() {
+
+
+
diff --git a/website/src/pages/Login/index.js b/website/src/pages/Login/index.js
index 27e27ea..9ad51ae 100644
--- a/website/src/pages/Login/index.js
+++ b/website/src/pages/Login/index.js
@@ -2,6 +2,10 @@ import React, { useEffect, useState} from 'react';
import { Form, Input, Button, Checkbox } from 'antd';
+import _auth from '@netuno/auth-client';
+
+import { Redirect } from "react-router-dom";
+
import './index.less';
const layout = {
@@ -13,14 +17,41 @@ const tailLayout = {
};
export default ()=> {
+ const [loading, setLoading] = useState(false);
+
const onFinish = (values) => {
- console.log('Success:', values);
+ setLoading(true);
+ _auth.login({
+ username: values.username,
+ password: values.password,
+ success: ()=> {
+ setLoading(false);
+ if (values.remember) {
+ localStorage.setItem("login", JSON.stringify(values));
+ } else {
+ localStorage.removeItem("login");
+ }
+ },
+ fail: ()=> {
+ setLoading(false);
+ alert("Fail.");
+ }
+ });
};
const onFinishFailed = (errorInfo) => {
console.log('Failed:', errorInfo);
};
+ let initialValues = {
+ remember: true,
+ };
+ if (localStorage.getItem("login")) {
+ initialValues = JSON.parse(localStorage.getItem("login"));
+ }
+ if (_auth.isLogged()) {
+ return ;
+ }
return (
Login
@@ -28,9 +59,7 @@ export default ()=> {
-
diff --git a/website/src/pages/Main/index.js b/website/src/pages/Main/index.js
new file mode 100644
index 0000000..5abc607
--- /dev/null
+++ b/website/src/pages/Main/index.js
@@ -0,0 +1,24 @@
+import React, { useEffect, useState} from 'react';
+
+import { Redirect } from "react-router-dom";
+
+import _auth from '@netuno/auth-client';
+
+import { Button } from 'antd';
+
+export default ()=> {
+ const [loading, setLoading] = useState(false);
+ if (!_auth.isLogged()) {
+ return
;
+ }
+ const onLogout = ()=> {
+ _auth.logout();
+ setLoading(true);
+ }
+ return (
+
+
Olá! Logado...
+ Sair
+
+ );
+};
diff --git a/website/src/pages/Main/index.less b/website/src/pages/Main/index.less
new file mode 100644
index 0000000..e69de29