Commit f37b8e10 authored by Kacprzak, Izabella's avatar Kacprzak, Izabella
Browse files

Enabled password change [BG, IK]

parent 1b5fd19a
Pipeline #202763 passed with stage
in 57 seconds
......@@ -119,7 +119,8 @@ def change_user_password():
if bcrypt.checkpw(oldPassword.encode('utf-8'), user.password.encode('utf-8')):
salt = bcrypt.gensalt()
hash_pswd = bcrypt.hashpw(newPassword.encode('utf-8'), salt)
user.password = hash_pswd
user.password = hash_pswd.decode('utf-8')
DB.add(user)
return jsonify(status = "True")
......
......@@ -49,15 +49,15 @@ function App() {
<Route exact path="/users">
<Users />
</Route>
<Route exact path="/users/change-password">
<ChangePassword />
</Route>
<Route exact path="/users/:username">
<User />
</Route>
<Route exact path="/edit-user/:username">
<EditUser />
</Route>
<Route exact path="/users/change-password">
<ChangePassword />
</Route>
</Route>
<Route exact path="/projects/:id/add-task">
<AddProjectTask />
</Route>
......
import useToken from './useToken';
import { useHistory } from 'react-router-dom'
import useState from 'react'
import { Link, useHistory } from 'react-router-dom'
import { useState } from 'react'
const ChangePassword = () =>{
const ChangePassword = () => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const {setToken, token} = useToken()
......@@ -15,10 +15,10 @@ async function passwordUpdate() {
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(
token,
oldPassword,
newPassword)
body: JSON.stringify({
username: token,
oldPassword: oldPassword,
newPassword: newPassword})
})
.then(data => data.json())
}
......@@ -31,7 +31,7 @@ async function passwordUpdate() {
document.getElementsByClassName("incorrect-password")[0].style.display = "block";
}
else{
history.push('/');
document.getElementsByClassName("password-changed-msg")[0].style.display = "block";
}
}
......@@ -53,13 +53,16 @@ return (
<button onClick={handleSubmit}>Change password</button>
<h2 className="incorrect-password" style={{display: "none"}}>Incorrect password</h2>
<div className="password-changed-msg" style={{display: "none"}}>
<h3>Your password has been changed successfully</h3>
<Link to={`/`}>Back to Dashboard</Link>
</div>
</div>
)
}
export default ChangePassword;
\ No newline at end of file
......@@ -30,7 +30,7 @@ export default function Login({ setToken }) {
return (
<div className="login">
<h1> InAGlobe Platform </h1>
<label> InAGlobe Platform </label>
<form onSubmit={handleSubmit}>
<input type="text" id="login" class="fadeIn second" name="login" placeholder="login"
onChange={e => setUserName(e.target.value)}/>
......
......@@ -157,7 +157,9 @@
margin-bottom: 30px;
}
.project-details button, .edit-project-button, .edit-user-button, .user button, .add-task-button, .view-tasks-button {
.create-project button, .project-details button, .edit-project-button, .add-user button, .edit-user-button, .user button, .add-task-button,
.view-tasks-button, .add-todo-form button, .add-project-task button,
.change-password .button, .login a, .login button {
background: #f1356d;
color: #fff;
border: 0;
......@@ -170,25 +172,27 @@
margin-right: 10px;
}
.project-details button:hover, .edit-project-button:hover, .edit-user-button:hover, .user button:hover, .add-task-button:hover, .view-tasks-button:hover{
.project-details button:hover, .edit-project-button:hover, .edit-user-button:hover, .user button:hover, .add-task-button:hover,
.view-tasks-button:hover, .change-password .button:hover, .login a:hover, .login button:hover{
background: #8f0830;
}
/* Create new project form and edit project */
.create-project .edit-project, .edit-user, .add-project-task{
.create-project .edit-project, .edit-user, .add-project-task, .change-password, .login{
max-width: 400px;
margin: 0 auto;
text-align: center;
}
.create-project label, .edit-project label, .add-user label, .edit-user label, .add-todo-form label,
.add-project-task label{
.create-project label, .edit-project label, .add-user label, .edit-user label, .add-todo-form label, .change-password label,
.add-project-task label, .login label{
text-align: left;
display: block;
font-size: 20px;
}
.create-project h2, .edit-project h2, .add-user h2, .edit-user h2, .add-todo-form h2, .add-project-task h2{
.create-project h2, .edit-project h2, .add-user h2, .edit-user h2, .add-todo-form h2, .add-project-task h2, .change-password h2,
.login h2{
font-size: 35px;
color: #f1356d;
margin-bottom: 30px;
......@@ -196,7 +200,7 @@
.create-project input, .create-project textarea, .create-project select,
.edit-project input, .edit-project textarea, .edit-project select, .add-user input,
.edit-user input, .add-todo-form input, .add-todo-form textarea, .add-todo-form select,
.add-project-task input, .add-project-task textarea, .add-project-task select{
.add-project-task input, .add-project-task textarea, .add-project-task select, .change-password input, .login input{
width: 100%;
padding: 6px 10px;
margin: 10px 0;
......@@ -204,19 +208,6 @@
box-sizing: border-box;
display: block;
}
.create-project button, .edit-project button, .add-user button, .edit-user button, .add-todo-form button,
.add-project-task button{
background: #f1356d;
color: #fff;
border: 0;
padding: 8px;
border-radius: 8px;
cursor: pointer;
font-size: 25px;
text-decoration: none;
margin-bottom: 30px;
margin-right: 10px;
}
.create-project button:hover, .edit-project button:hover, .add-user button:hover, .edit-user button:hover, .todo-list button:hover,
.add-project-task button:hover {
......@@ -510,23 +501,3 @@ Note: Beware of modifying this element as it can break the animations - you shou
margin-bottom: 10px;
margin-right: 10px;
}
/* Login Page */
.login {
text-align: center;
}
.login h1 {
color: #f1356d;
margin-bottom: 10px;
}
.login input {
padding: 6px 10px;
margin: 10px 0;
border: 1px solid #ddd;
box-sizing: border-box;
display: block;
align-items: center;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment