fixed many small problems, login now seems to work
This commit is contained in:
parent
543fd56116
commit
e42b0fb7aa
@ -13,6 +13,7 @@
|
||||
"react-router-dom": "^6.22.3",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-validation": "^3.0.7",
|
||||
"html-react-parser": "^5.1.9",
|
||||
"validator": "^13.11.0",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
|
||||
@ -97,7 +97,7 @@ class App extends Component {
|
||||
<div className="navbar-nav ml-auto">
|
||||
<li className="nav-item">
|
||||
<Link to={"/profile"} className="nav-link">
|
||||
{currentUser.username}
|
||||
{currentUser.user_name}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
|
||||
@ -1,21 +1,24 @@
|
||||
import React, { Component } from 'react';
|
||||
import UserService from '../services/user.service';
|
||||
import parse from 'html-react-parser';
|
||||
|
||||
export default class Home extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
content: ""
|
||||
content: "",
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
UserService.getPublicContent().then(
|
||||
response => {
|
||||
var bodyHtml = /<body.*?>([\s\S]*)<\/body>/.exec(response.data)[1];
|
||||
this.setState({
|
||||
content: response.data
|
||||
content: bodyHtml
|
||||
});
|
||||
|
||||
},
|
||||
error => {
|
||||
this.setState({
|
||||
@ -32,8 +35,10 @@ export default class Home extends Component {
|
||||
return (
|
||||
<div className="container">
|
||||
<header className="jumbotron">
|
||||
<h2>lala</h2>
|
||||
<h3>{this.state.content}</h3>
|
||||
<h2>Default home page</h2>
|
||||
<div name="contentDiv">
|
||||
{parse(this.state.content)}
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -59,7 +59,7 @@ class Login extends Component {
|
||||
if (this.checkBtn.context._errors.length === 0) {
|
||||
AuthService.login(this.state.username, this.state.password).then(
|
||||
() => {
|
||||
this.props.navigate('/profile');
|
||||
this.props.router.navigate('/profile');
|
||||
window.location.reload();
|
||||
},
|
||||
error => {
|
||||
|
||||
@ -9,7 +9,7 @@ export default class Profile extends Component {
|
||||
this.state = {
|
||||
redirect: null,
|
||||
userReady: false,
|
||||
currentUser: {username: ""}
|
||||
currentUser: {username: "", token: "", id: "", email: ""}
|
||||
};
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ export default class Profile extends Component {
|
||||
const { currentUser } = this.state;
|
||||
|
||||
return (
|
||||
<Component>
|
||||
<div className="container">
|
||||
<header className="jumbotron">
|
||||
<h3>
|
||||
@ -39,7 +38,7 @@ export default class Profile extends Component {
|
||||
</h3>
|
||||
</header>
|
||||
<p>
|
||||
<strong>Token:</strong>{ currentUser.accessToken.substring(0, 20) } { currentUser.accessToken.substr(currentUser.accessToken.length - 20) }
|
||||
<strong>Token:</strong> { currentUser.token }
|
||||
</p>
|
||||
<p>
|
||||
<strong>Id:</strong>{ currentUser.id }
|
||||
@ -47,12 +46,8 @@ export default class Profile extends Component {
|
||||
<p>
|
||||
<strong>Email:</strong>{ currentUser.email }
|
||||
</p>
|
||||
<strong>Authorities:</strong>
|
||||
<ul>
|
||||
{currentUser.roles && currentUser.roles.map((role, index) => <li key={index}>{role}</li>)}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</Component>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -28,4 +28,5 @@ class UserService {
|
||||
|
||||
}
|
||||
|
||||
export default new UserService();
|
||||
const userService = new UserService();
|
||||
export default userService;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user