Commit 6768b3c7 authored by ras19's avatar ras19
Browse files

Merged user login and changing password functionality done in user_login branch [RS, IK, BG, EW]

parents 0d4c180d f37b8e10
Pipeline #202768 passed with stages
in 2 minutes and 27 seconds
from flask import Blueprint, request, jsonify, Response
from backend.database_config.database import DB
from backend.models.user_model import User
import json
import bcrypt
user = Blueprint('user', __name__)
......@@ -46,7 +46,10 @@ def add_user():
request.json['email'], request.json['bio'], request.json['joined'],
request.json['location'],request.json['availability'],
request.json['partnership_opportunities'], request.json['interests'])
entry = User(username = username, firstname = firstname, surname = surname, password = password,
salt = bcrypt.gensalt()
hash_pswd = bcrypt.hashpw(password.encode('utf-8'), salt).decode('utf-8')
entry = User(username = username, firstname = firstname, surname = surname, password = hash_pswd,
title = title, email = email, bio = bio, joined = joined, location = location,
availability = availability, partnership_opportunities = partnership_opportunities,
interests = interests)
......@@ -67,7 +70,12 @@ def update_user(username):
request.json['partnership_opportunities'], request.json['interests'])
entry.firstname = firstname
entry.surname = surname
entry.password = password
salt = bcrypt.gensalt()
hash_pswd = bcrypt.hashpw(password.encode('utf-8'), salt)
entry.password = hash_pswd
entry.title = title
entry.email = email
entry.bio = bio
......@@ -87,3 +95,35 @@ def delete_user(username):
return ''
@user.route('/users/login', methods = ['POST'])
def user_login():
username, password = (request.json['username'], request.json['password'])
user = User.query.get(username)
if user == None:
return jsonify(token = "")
if bcrypt.checkpw(password.encode('utf-8'), user.password.encode('utf-8')):
return jsonify(token = username)
else:
return jsonify(token = "")
@user.route('/users/update-password', methods = ['POST'])
def change_user_password():
username, oldPassword, newPassword = (request.json['username'], request.json['oldPassword'],
request.json['newPassword'])
user = User.query.get(username)
if user == None:
return jsonify(status = "False")
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.decode('utf-8')
DB.add(user)
return jsonify(status = "True")
else:
return jsonify(status = "False")
{
"files": {
"main.css": "/static/react/css/main.953731b2.chunk.css",
"main.js": "/static/react/js/main.2bf19c42.chunk.js",
"main.js.map": "/static/react/js/main.2bf19c42.chunk.js.map",
"main.css": "/static/react/css/main.dd5917b5.chunk.css",
"main.js": "/static/react/js/main.66bb16bd.chunk.js",
"main.js.map": "/static/react/js/main.66bb16bd.chunk.js.map",
"runtime-main.js": "/static/react/js/runtime-main.d0ba4578.js",
"runtime-main.js.map": "/static/react/js/runtime-main.d0ba4578.js.map",
"js/2.dc570757.chunk.js": "/static/react/js/2.dc570757.chunk.js",
"js/2.dc570757.chunk.js.map": "/static/react/js/2.dc570757.chunk.js.map",
"js/2.3bffcab4.chunk.js": "/static/react/js/2.3bffcab4.chunk.js",
"js/2.3bffcab4.chunk.js.map": "/static/react/js/2.3bffcab4.chunk.js.map",
"js/3.c9f8f6ff.chunk.js": "/static/react/js/3.c9f8f6ff.chunk.js",
"js/3.c9f8f6ff.chunk.js.map": "/static/react/js/3.c9f8f6ff.chunk.js.map",
"../../templates/index.html": "/static/react/../../templates/index.html",
"css/main.953731b2.chunk.css.map": "/static/react/css/main.953731b2.chunk.css.map",
"js/2.dc570757.chunk.js.LICENSE.txt": "/static/react/js/2.dc570757.chunk.js.LICENSE.txt"
"css/main.dd5917b5.chunk.css.map": "/static/react/css/main.dd5917b5.chunk.css.map",
"js/2.3bffcab4.chunk.js.LICENSE.txt": "/static/react/js/2.3bffcab4.chunk.js.LICENSE.txt"
},
"entrypoints": [
"js/runtime-main.d0ba4578.js",
"js/2.dc570757.chunk.js",
"css/main.953731b2.chunk.css",
"js/main.2bf19c42.chunk.js"
"js/2.3bffcab4.chunk.js",
"css/main.dd5917b5.chunk.css",
"js/main.66bb16bd.chunk.js"
]
}
\ No newline at end of file
@import url(https://fonts.googleapis.com/css2?family=Raleway:wght@100&display=swap);*{margin:0;font-family:"Raleway";color:#000;background-color:#fff}.home h1{font-style:bold;font-size:50px;text-align:left;margin-bottom:50px}.home h2{margin-top:10px;padding:4px}.home button{background-color:#ff4e83;color:#000;padding:15px 32px;font-size:20px;border-radius:12px}.home button:hover{background-color:#8f0830}.navbar{padding:20px;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;max-width:1000px;margin:0 auto;border-bottom:1px solid #f2f2f2}.navbar,.navbar h1{color:#ff4e83}.navbar .links{margin-left:auto}.navbar a{margin-left:16px;text-decoration:none;padding:6px;color:#000}.navbar a:hover{color:#f1356d}.content{max-width:1000px;padding:20px;margin:20px auto}.preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2}.preview:hover{box-shadow:1px 3px 5px grey}.preview h2{font-size:20;color:#f1356d;padding-left:4px}.preview h3{font-size:10;color:#000;padding-bottom:20px;padding-left:4px}.preview a{text-decoration:none}.user{width:1000px;margin-bottom:30px;background-color:#fff}.user h2{font-size:32px;font-weight:600;margin-bottom:15px;color:#333}.user h3{font-size:15px;color:#222729}.user h3,.user h4{letter-spacing:1px;margin-bottom:5px}.user h4{font-size:10px;color:#00baff;font-weight:700}.user p{font-size:16px;line-height:26px;margin-bottom:20px;color:#666}.project-details h2,.user h2{font-size:35px;color:#f1356d;margin-bottom:10px}.project-details h4,.user h4{font-size:20px;color:#272424;margin-bottom:30px}.project-details p{font-size:20px;color:#080808;margin-bottom:30px}.add-task-button,.edit-project-button,.edit-user-button,.project-details button,.user button,.view-tasks-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}.add-task-button:hover,.edit-project-button:hover,.edit-user-button:hover,.project-details button:hover,.user button:hover,.view-tasks-button:hover{background:#8f0830}.add-project-task,.create-project .edit-project,.edit-user{max-width:400px;margin:0 auto;text-align:center}.add-project-task label,.add-todo-form label,.add-user label,.create-project label,.edit-project label,.edit-user label{text-align:left;display:block;font-size:20px}.add-project-task h2,.add-todo-form h2,.add-user h2,.create-project h2,.edit-project h2,.edit-user h2{font-size:35px;color:#f1356d;margin-bottom:30px}.add-project-task input,.add-project-task select,.add-project-task textarea,.add-todo-form input,.add-todo-form select,.add-todo-form textarea,.add-user input,.create-project input,.create-project select,.create-project textarea,.edit-project input,.edit-project select,.edit-project textarea,.edit-user input{width:100%;padding:6px 10px;margin:10px 0;border:1px solid #ddd;box-sizing:border-box;display:block}.add-project-task button,.add-todo-form button,.add-user button,.create-project button,.edit-project button,.edit-user 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}.add-project-task button:hover,.add-user button:hover,.create-project button:hover,.edit-project button:hover,.edit-user button:hover,.todo-list button:hover{background:#8f0830}.my-profile h2{font-size:35px;color:#f1356d;margin-bottom:10px}.my-profile p{font-size:20px;color:#080808;margin-bottom:30px}.page-not-found h2,.page-not-found p{margin-bottom:10px}.add-project-task label,.add-user label{text-align:left;display:block;font-size:20px}.users h1{font-style:bold;font-size:50px;text-align:left;margin-bottom:50px}.bm-burger-button{position:fixed;width:36px;height:30px;left:36px;top:36px}.bm-burger-bars{background:#373a47}.bm-burger-bars-hover{background:#a90000}.bm-cross-button{height:24px;width:24px}.bm-cross{background:#248f0f}.bm-menu-wrap{position:fixed;height:100%}.bm-menu{background:#373a47;padding:2.5em 1.5em 0;font-size:1.15em}.bm-morph-shape{fill:#373a47}.bm-item-list{color:#5a0808;padding:.8em}.bm-overlay{background:rgba(0,0,0,.3)}.bm-item{display:inline-block;color:#5d076e;margin-bottom:10px;text-align:left;text-decoration:none;transition:color .2s}.bm-item:hover{color:#000}.personal-todos{display:block;max-height:1000px;overflow-x:hidden;overflow-y:auto}.todo-preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2;max-width:300px}.todo-preview:hover{box-shadow:1px 3px 5px grey}.todo-preview h2{padding-top:10px;font-size:20;color:#e66a12;padding-bottom:7px}.todo-preview h3{font-size:10;color:#000;padding-bottom:7px;padding-left:4px}.todo-preview button{background:#e66a12;color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:25px;text-decoration:none;margin-bottom:10px;margin-left:4px;margin-top:5px}.todo-preview button:hover{background:#a55b27}.add-todo-label{background:#e66a12;color:#fff;text-align:center;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:35px;text-decoration:none;margin:15px}.add-todo-label:hover{background:#a55b27}.add-todo-form{max-width:400px;margin:0 auto;text-align:center;display:none}.add-todo-button button{background:#e66a12;color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:25px;text-decoration:none;margin-bottom:30px;margin-right:10px}.add-todo-button button:hover{background:#a55b27}.project-tasks{margin-bottom:30px}.project-tasks h2{padding-top:10px;padding-bottom:10px}.project-task-preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2}.project-task-preview:hover{box-shadow:1px 3px 5px grey}.project-task-preview h2{font-size:20;color:#f1356d;padding-left:4px}.project-task-preview h3{font-size:10;color:#000;padding-bottom:7px;padding-left:4px}.project-task-preview a{text-decoration:none}.add-task-button-wrapper{margin-top:30px}.task-complete-button{background:#00f}.task-complete-button,.task-delete-button{color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:20px;text-decoration:none;margin-bottom:10px;margin-right:10px}.task-delete-button{background:green}
/*# sourceMappingURL=main.953731b2.chunk.css.map */
\ No newline at end of file
This diff is collapsed.
@import url(https://fonts.googleapis.com/css2?family=Raleway:wght@100&display=swap);*{margin:0;font-family:"Raleway";color:#000;background-color:#fff}.home h1{font-style:bold;font-size:50px;text-align:left;margin-bottom:50px}.home h2{margin-top:10px;padding:4px}.home button{background-color:#ff4e83;color:#000;padding:15px 32px;font-size:20px;border-radius:12px}.home button:hover{background-color:#8f0830}.navbar{padding:20px;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;max-width:1000px;margin:0 auto;border-bottom:1px solid #f2f2f2}.navbar,.navbar h1{color:#ff4e83}.navbar .links{margin-left:auto}.navbar a{margin-left:16px;text-decoration:none;padding:6px;color:#000}.navbar a:hover{color:#f1356d}.content{max-width:1000px;padding:20px;margin:20px auto}.preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2}.preview:hover{box-shadow:1px 3px 5px grey}.preview h2{font-size:20;color:#f1356d;padding-left:4px}.preview h3{font-size:10;color:#000;padding-bottom:20px;padding-left:4px}.preview a{text-decoration:none}.user{width:1000px;margin-bottom:30px;background-color:#fff}.user h2{font-size:32px;font-weight:600;margin-bottom:15px;color:#333}.user h3{font-size:15px;color:#222729}.user h3,.user h4{letter-spacing:1px;margin-bottom:5px}.user h4{font-size:10px;color:#00baff;font-weight:700}.user p{font-size:16px;line-height:26px;margin-bottom:20px;color:#666}.project-details h2,.user h2{font-size:35px;color:#f1356d;margin-bottom:10px}.project-details h4,.user h4{font-size:20px;color:#272424;margin-bottom:30px}.project-details p{font-size:20px;color:#080808;margin-bottom:30px}.add-project-task button,.add-task-button,.add-todo-form button,.add-user button,.change-password .button,.create-project button,.edit-project-button,.edit-user-button,.login a,.login button,.project-details button,.user button,.view-tasks-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}.add-task-button:hover,.change-password .button:hover,.edit-project-button:hover,.edit-user-button:hover,.login a:hover,.login button:hover,.project-details button:hover,.user button:hover,.view-tasks-button:hover{background:#8f0830}.add-project-task,.change-password,.create-project .edit-project,.edit-user,.login{max-width:400px;margin:0 auto;text-align:center}.add-project-task label,.add-todo-form label,.add-user label,.change-password label,.create-project label,.edit-project label,.edit-user label,.login label{text-align:left;display:block;font-size:20px}.add-project-task h2,.add-todo-form h2,.add-user h2,.change-password h2,.create-project h2,.edit-project h2,.edit-user h2,.login h2{font-size:35px;color:#f1356d;margin-bottom:30px}.add-project-task input,.add-project-task select,.add-project-task textarea,.add-todo-form input,.add-todo-form select,.add-todo-form textarea,.add-user input,.change-password input,.create-project input,.create-project select,.create-project textarea,.edit-project input,.edit-project select,.edit-project textarea,.edit-user input,.login input{width:100%;padding:6px 10px;margin:10px 0;border:1px solid #ddd;box-sizing:border-box;display:block}.add-project-task button:hover,.add-user button:hover,.create-project button:hover,.edit-project button:hover,.edit-user button:hover,.todo-list button:hover{background:#8f0830}.my-profile h2{font-size:35px;color:#f1356d;margin-bottom:10px}.my-profile p{font-size:20px;color:#080808;margin-bottom:30px}.page-not-found h2,.page-not-found p{margin-bottom:10px}.add-project-task label,.add-user label{text-align:left;display:block;font-size:20px}.users h1{font-style:bold;font-size:50px;text-align:left;margin-bottom:50px}.bm-burger-button{position:fixed;width:36px;height:30px;left:36px;top:36px}.bm-burger-bars{background:#373a47}.bm-burger-bars-hover{background:#a90000}.bm-cross-button{height:24px;width:24px}.bm-cross{background:#248f0f}.bm-menu-wrap{position:fixed;height:100%}.bm-menu{padding:2.5em 1.5em 0;font-size:1.15em}.bm-morph-shape{fill:#373a47}.bm-item-list{color:#5a0808;padding:.8em}.bm-overlay{background:rgba(0,0,0,.3)}.bm-item{display:inline-block;color:#5d076e;margin-bottom:10px;text-align:left;text-decoration:none;transition:color .2s}.bm-item:hover{color:#000}.personal-todos{display:block;max-height:1000px;overflow-x:hidden;overflow-y:auto}.todo-preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2;max-width:300px}.todo-preview:hover{box-shadow:1px 3px 5px grey}.todo-preview h2{padding-top:10px;font-size:20;color:#e66a12;padding-bottom:7px}.todo-preview h3{font-size:10;color:#000;padding-bottom:7px;padding-left:4px}.todo-preview button{background:#e66a12;color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:25px;text-decoration:none;margin-bottom:10px;margin-left:4px;margin-top:5px}.todo-preview button:hover{background:#a55b27}.add-todo-label{background:#e66a12;color:#fff;text-align:center;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:35px;text-decoration:none;margin:15px}.add-todo-label:hover{background:#a55b27}.add-todo-form{max-width:400px;margin:0 auto;text-align:center;display:none}.add-todo-button button{background:#e66a12;color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:25px;text-decoration:none;margin-bottom:30px;margin-right:10px}.add-todo-button button:hover{background:#a55b27}.project-tasks{margin-bottom:30px}.project-tasks h2{padding-top:10px;padding-bottom:10px}.project-task-preview{padding:6px;border-bottom:1px;border-radius:5px;margin:2px 2px 10px;box-shadow:1px 3px 5px #c2c2c2}.project-task-preview:hover{box-shadow:1px 3px 5px grey}.project-task-preview h2{font-size:20;color:#f1356d;padding-left:4px}.project-task-preview h3{font-size:10;color:#000;padding-bottom:7px;padding-left:4px}.project-task-preview a{text-decoration:none}.add-task-button-wrapper{margin-top:30px}.task-complete-button{background:#00f}.task-complete-button,.task-delete-button{color:#fff;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:20px;text-decoration:none;margin-bottom:10px;margin-right:10px}.task-delete-button{background:green}
/*# sourceMappingURL=main.dd5917b5.chunk.css.map */
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/react/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/react/logo192.png"/><link rel="manifest" href="/static/react/manifest.json"/><title>React App</title><script>window.token="{{DRP_token}}"</script><link href="/static/react/css/main.953731b2.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)u=i[s],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return a.push.apply(a,l||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,i=document.createElement("script");i.charset="utf-8",i.timeout=120,u.nc&&i.setAttribute("nonce",u.nc),i.src=function(e){return u.p+"js/"+({}[e]||e)+"."+{3:"c9f8f6ff"}[e]+".chunk.js"}(e);var c=new Error;a=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){a({type:"timeout",target:i})}),12e4);i.onerror=i.onload=a,document.head.appendChild(i)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/static/react/",u.oe=function(e){throw console.error(e),e};var i=this["webpackJsonpinaglobe-dashboard"]=this["webpackJsonpinaglobe-dashboard"]||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/react/js/2.dc570757.chunk.js"></script><script src="/static/react/js/main.2bf19c42.chunk.js"></script></body></html>
\ No newline at end of file
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/react/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/react/logo192.png"/><link rel="manifest" href="/static/react/manifest.json"/><title>React App</title><script>window.token="{{DRP_token}}"</script><link href="/static/react/css/main.dd5917b5.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)u=i[s],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return a.push.apply(a,l||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,i=document.createElement("script");i.charset="utf-8",i.timeout=120,u.nc&&i.setAttribute("nonce",u.nc),i.src=function(e){return u.p+"js/"+({}[e]||e)+"."+{3:"c9f8f6ff"}[e]+".chunk.js"}(e);var c=new Error;a=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){a({type:"timeout",target:i})}),12e4);i.onerror=i.onload=a,document.head.appendChild(i)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/static/react/",u.oe=function(e){throw console.error(e),e};var i=this["webpackJsonpinaglobe-dashboard"]=this["webpackJsonpinaglobe-dashboard"]||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/react/js/2.3bffcab4.chunk.js"></script><script src="/static/react/js/main.66bb16bd.chunk.js"></script></body></html>
\ No newline at end of file
This diff is collapsed.
......@@ -21,6 +21,7 @@
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bcrypt": "^5.0.1",
"bfj": "^7.0.2",
"camelcase": "^6.1.0",
"case-sensitive-paths-webpack-plugin": "2.3.0",
......
import React, { useState } from 'react';
import {HashRouter as Router, Route, Switch} from 'react-router-dom'
import Navbar from './Navbar'
import Home from './Home'
import CreateProject from './CreateProject'
import {HashRouter as Router, Route, Switch} from 'react-router-dom'
import ProjectDetails from './ProjectDetails'
import PageNotFound from './PageNotFound'
import MyProfile from './MyProfile'
......@@ -13,15 +15,24 @@ import Sidebar from './Sidebar'
import EditUser from './EditUser'
import ProjectTasks from './ProjectTasks'
import AddProjectTask from './AddProjectTask'
import Login from './Login'
import useToken from './useToken';
import ChangePassword from './ChangePassword';
function App() {
const title = "Dashboard"
const { token, setToken } = useToken();
if(!token) {
return <Login setToken={setToken} />
}
return (
<Router>
<div className="App">
<div className="App">
<Sidebar />
<Navbar />
<div className="content">
<div className="content">
<Switch>
<Route exact path="/">
<Home />
......@@ -38,12 +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>
<Route exact path="/projects/:id/add-task">
<AddProjectTask />
</Route>
......
import useToken from './useToken';
import { Link, useHistory } from 'react-router-dom'
import { useState } from 'react'
const ChangePassword = () => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const {setToken, token} = useToken()
const history = useHistory()
async function passwordUpdate() {
return fetch('/users/update-password', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: token,
oldPassword: oldPassword,
newPassword: newPassword})
})
.then(data => data.json())
}
const handleSubmit = async e => {
e.preventDefault();
const updated = await passwordUpdate();
if(updated.status != "True") {
document.getElementsByClassName("incorrect-password")[0].style.display = "block";
}
else{
document.getElementsByClassName("password-changed-msg")[0].style.display = "block";
}
}
return (
<div className="change-password">
<h2>Change Password</h2>
<label >Current Password</label>
<input
onChange={(e) => setOldPassword(e.target.value)}
placeholder="Current Password"
/>
<label >New Password</label>
<input
onChange={(e) => setNewPassword(e.target.value)}
placeholder="New Password"
/>
<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
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