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

Implemented forgot password functionality - email with new password is sent [IK]

parent 367966f7
Pipeline #203331 passed with stage
in 1 minute and 15 seconds
......@@ -2,6 +2,8 @@ from flask import Blueprint, request, jsonify, Response
from backend.database_config.database import DB
from backend.models.user_model import User
from backend.models.user_model import User_project
from backend.main import Message
import backend.main
import bcrypt
user = Blueprint('user', __name__)
......@@ -142,3 +144,22 @@ def change_user_password():
else:
return jsonify(status = "False")
@user.route('/users/forgot-password', methods=['POST'])
def send_auth_email():
username, newPassword = (request.json['username'], request.json['newPassword'])
user = User.query.get(username)
if user == None:
return jsonify(status = "False")
msg = Message(subject="Password reset",
sender=backend.main.app.config.get("MAIL_USERNAME"),
recipients=[user.email],
body="Your new password is: " + newPassword)
salt = bcrypt.gensalt()
hash_pswd = bcrypt.hashpw(newPassword.encode('utf-8'), salt)
user.password = hash_pswd.decode('utf-8')
DB.add(user)
backend.main.mail.send(msg)
return jsonify(status = "True")
\ No newline at end of file
import os
from flask import Flask, render_template
from flask_migrate import Migrate
from flask_mail import Mail, Message
from backend.database_config.database import DB
from backend.blueprints.project import project
from backend.blueprints.user import user
......@@ -25,6 +26,19 @@ if ENV == 'dev':
else:
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://icbwsbzlctcxyx:a0d7f73e5b743a35f33d95640b517b6e7e9e5b59cd2ff10673e90372b4b34d44@ec2-34-193-112-164.compute-1.amazonaws.com:5432/deje5qriuvrh39'
# Mail settings for "forgot password" mail sending
mail_settings = {
"MAIL_SERVER": 'smtp.gmail.com',
"MAIL_PORT": 465,
"MAIL_USE_TLS": False,
"MAIL_USE_SSL": True,
"MAIL_USERNAME": 'inaglobe.authentication@gmail.com',
"MAIL_PASSWORD": '5Q4g>kQ&c'
}
app.config.update(mail_settings)
mail = Mail(app)
db = DB.the_database
db.app = app
......
{
"files": {
"main.css": "/static/react/css/main.893b1949.chunk.css",
"main.js": "/static/react/js/main.e896a0a2.chunk.js",
"main.js.map": "/static/react/js/main.e896a0a2.chunk.js.map",
"main.css": "/static/react/css/main.f61942a0.chunk.css",
"main.js": "/static/react/js/main.e1037ace.chunk.js",
"main.js.map": "/static/react/js/main.e1037ace.chunk.js.map",
"runtime-main.js": "/static/react/js/runtime-main.094287be.js",
"runtime-main.js.map": "/static/react/js/runtime-main.094287be.js.map",
"js/2.92bb91cc.chunk.js": "/static/react/js/2.92bb91cc.chunk.js",
"js/2.92bb91cc.chunk.js.map": "/static/react/js/2.92bb91cc.chunk.js.map",
"js/2.e23a4f2d.chunk.js": "/static/react/js/2.e23a4f2d.chunk.js",
"js/2.e23a4f2d.chunk.js.map": "/static/react/js/2.e23a4f2d.chunk.js.map",
"js/3.ddc4d6e7.chunk.js": "/static/react/js/3.ddc4d6e7.chunk.js",
"js/3.ddc4d6e7.chunk.js.map": "/static/react/js/3.ddc4d6e7.chunk.js.map",
"../../templates/index.html": "/static/react/../../templates/index.html",
"css/main.893b1949.chunk.css.map": "/static/react/css/main.893b1949.chunk.css.map",
"js/2.92bb91cc.chunk.js.LICENSE.txt": "/static/react/js/2.92bb91cc.chunk.js.LICENSE.txt"
"css/main.f61942a0.chunk.css.map": "/static/react/css/main.f61942a0.chunk.css.map",
"js/2.e23a4f2d.chunk.js.LICENSE.txt": "/static/react/js/2.e23a4f2d.chunk.js.LICENSE.txt"
},
"entrypoints": [
"js/runtime-main.094287be.js",
"js/2.92bb91cc.chunk.js",
"css/main.893b1949.chunk.css",
"js/main.e896a0a2.chunk.js"
"js/2.e23a4f2d.chunk.js",
"css/main.f61942a0.chunk.css",
"js/main.e1037ace.chunk.js"
]
}
\ 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{padding-bottom:20px}.preview h3,.preview h4{font-size:10;color:#000;padding-left:4px}.preview h4{padding-bottom:5px;padding-top:5px}.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,.add-user button,.change-password .button,.create-project button,.edit-project-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-project-task button:hover .view-tasks-button:hover,.add-task-button:hover,.add-user-button:hover,.add-user button:hover,.change-password .button:hover,.create-project button:hover,.edit-project-button:hover,.edit-project button:hover,.edit-user-button:hover,.edit-user button:hover,.project-details button:hover,.todo-list button:hover,.user button:hover{background:#8f0830}.assigned_users_preview{padding:6px;margin:2px;border-bottom:1px;border-radius:5px;box-shadow:1px 3px 5px #c2c2c2}.assigned_users_preview:hover{box-shadow:1px 3px 5px grey}.assigned_users_preview h4{font-size:10;color:#000;padding-bottom:5px;padding-top:5px;padding-left:4px}.assigned_users_preview a{text-decoration:none}.project_user_assignment_list{margin-bottom:30px;margin-right:10px}.add-project-task,.change-password,.create-project .edit-project,.edit-user{max-width:400px;margin:0 auto;text-align:center}.login{margin:0;position:absolute;top:50%;left:50%;width:500px;height:350px;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);box-shadow:1px 3px 5px #c2c2c2;border-radius:6px;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{text-align:left;display:block;font-size:20px;-webkit-align-items:center;align-items:center}.login h1{font-size:40px;color:#f1356d;margin-bottom:20px;margin-top:20px;-webkit-align-items:center;align-items:center}.login a{font-size:20px;color:#35a6f1;text-decoration:underline;margin:8px 0 10px}.login a,.login button{padding:14px 20px;border:none;cursor:pointer}.login button{background:#f1356d;color:#fff;font-size:25px}.login button,.login input{width:450px;margin:8px 0 20px}.login input{padding:12px 20px;display:inline-block;border:1px solid #ccc;box-sizing:border-box;font-size:15px}.login .button:hover{background:#8f0830}.add-project-task h2,.add-todo-form h2,.add-user h2,.change-password 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,.change-password 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}.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:30px}.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;background-color:#f0b995}.todo-preview:hover{box-shadow:1px 3px 5px grey}.todo-preview h2{padding-top:10px;font-size:30px;font-weight:bolder}.todo-preview h2,.todo-preview h3{color:#000;padding-bottom:7px;background-color:#f0b995}.todo-preview h3{font-size:15px;padding-left:4px}.todo-preview button{background:#89e63d;color:#000;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:15px;text-decoration:none;margin-bottom:10px;margin-left:4px;margin-top:5px}.todo-preview button:hover{background:#548d25}.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}.dropdown{max-width:400px}
/*# sourceMappingURL=main.893b1949.chunk.css.map */
\ 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{padding-bottom:20px}.preview h3,.preview h4{font-size:10;color:#000;padding-left:4px}.preview h4{padding-bottom:5px;padding-top:5px}.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,.add-user button,.change-password .button,.create-project button,.edit-project-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-project-task button:hover .view-tasks-button:hover,.add-task-button:hover,.add-user-button:hover,.add-user button:hover,.change-password .button:hover,.create-project button:hover,.edit-project-button:hover,.edit-project button:hover,.edit-user-button:hover,.edit-user button:hover,.project-details button:hover,.todo-list button:hover,.user button:hover{background:#8f0830}.assigned_users_preview{padding:6px;margin:2px;border-bottom:1px;border-radius:5px;box-shadow:1px 3px 5px #c2c2c2}.assigned_users_preview:hover{box-shadow:1px 3px 5px grey}.assigned_users_preview h4{font-size:10;color:#000;padding-bottom:5px;padding-top:5px;padding-left:4px}.assigned_users_preview a{text-decoration:none}.project_user_assignment_list{margin-bottom:30px;margin-right:10px}.add-project-task,.change-password,.create-project .edit-project,.edit-user{max-width:400px;margin:0 auto;text-align:center}.forgot-password,.login{margin:0;position:absolute;top:50%;left:50%;width:500px;height:430px;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);box-shadow:1px 3px 5px #c2c2c2;border-radius:6px;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{text-align:left;display:block;font-size:20px;-webkit-align-items:center;align-items:center}.forgot-password h1,.login h1{font-size:40px;color:#f1356d;margin-bottom:20px}.forgot-password h1,.forgot-password h2,.login h1,.login h2{margin-top:20px;-webkit-align-items:center;align-items:center}.forgot-password h2,.login h2{font-size:20px;color:#271a1e;margin-bottom:10px}.login .links{font-size:20px;color:#35a6f1;text-decoration:underline;padding:14px 20px;margin:8px 0 10px;border:none;cursor:pointer}.forgot-password button,.login button{background:#f1356d;color:#fff;padding:14px 20px;border:none;cursor:pointer;width:450px;margin:8px 0 20px;font-size:25px}.forgot-password input,.login input{width:450px;padding:12px 20px;margin:8px 0 20px;display:inline-block;border:1px solid #ccc;box-sizing:border-box;font-size:15px}.forgot-password button:hover,.login .button:hover{background:#8f0830}.add-project-task h2,.add-todo-form h2,.add-user h2,.change-password 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,.change-password 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}.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:30px}.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;background-color:#f0b995}.todo-preview:hover{box-shadow:1px 3px 5px grey}.todo-preview h2{padding-top:10px;font-size:30px;font-weight:bolder}.todo-preview h2,.todo-preview h3{color:#000;padding-bottom:7px;background-color:#f0b995}.todo-preview h3{font-size:15px;padding-left:4px}.todo-preview button{background:#89e63d;color:#000;border:0;padding:8px;border-radius:8px;cursor:pointer;font-size:15px;text-decoration:none;margin-bottom:10px;margin-left:4px;margin-top:5px}.todo-preview button:hover{background:#548d25}.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}.dropdown{max-width:400px}
/*# sourceMappingURL=main.f61942a0.chunk.css.map */
\ No newline at end of file
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.893b1949.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:"ddc4d6e7"}[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.92bb91cc.chunk.js"></script><script src="/static/react/js/main.e896a0a2.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.f61942a0.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:"ddc4d6e7"}[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.e23a4f2d.chunk.js"></script><script src="/static/react/js/main.e1037ace.chunk.js"></script></body></html>
\ No newline at end of file
......@@ -16,16 +16,28 @@ import EditUser from './EditUser'
import ProjectTasks from './ProjectTasks'
import AddProjectTask from './AddProjectTask'
import Login from './Login'
import useToken from './useToken';
import ChangePassword from './ChangePassword';
import useToken from './useToken'
import ChangePassword from './ChangePassword'
import ProjectsRegistry from './ProjectsRegistry'
import ForgotPassword from './ForgotPassword'
function App() {
const { token, setToken } = useToken();
if(!token) {
return <Login setToken={setToken} />
return (
<Router>
<Switch>
<Route exact path="/forgot-password">
<ForgotPassword />
</Route>
<Route path="*">
<Login setToken={setToken} />
</Route>
</Switch>
</Router>
)
}
return (
......
import { useState } from "react";
async function resetPassword(msg) {
return fetch('/users/forgot-password', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(msg)
})
.then(data => data.json())
}
const ForgotPassword = () => {
const [username, setUsername] = useState();
const handleSubmit = async e => {
e.preventDefault();
const msg = {
username: username,
newPassword: Math.random().toString(36).replace(/[^a-z]+/g, '')
}
const response = await resetPassword(msg);
if(response.status == "False") {
document.getElementsByClassName("incorrect-username")[0].style.display = "block";
} else {
document.getElementsByClassName("email-sent")[0].style.display = "block";
}
}
return (
<div className="forgot-password">
<form onSubmit={handleSubmit}>
<h1>Forgot Password</h1>
<h2>Input your username</h2>
<input type="text" onChange={e => setUsername(e.target.value)}/>
<div className="incorrect-username" style={{display: 'none'}}>
<h2>Incorrect username provided!</h2>
</div>
<div className="email-sent" style={{display: 'none'}}>
<h2>Email has been sent!</h2>
</div>
<button>Submit</button>
</form>
</div>
);
}
export default ForgotPassword;
\ No newline at end of file
import { useState } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom'
async function loginUser(credentials) {
return fetch('/users/login', {
......@@ -24,8 +25,11 @@ export default function Login({ setToken }) {
});
if(token.token != "") {
setToken(token);
} else {
document.getElementsByClassName("incorrect-password")[0].style.display = "block";
}
}
}
return (
......@@ -39,7 +43,9 @@ export default function Login({ setToken }) {
<div className="incorrect-password" style={{display: 'none'}}>
<h2>Incorrect password!</h2>
</div>
<a>Forgot Password?</a>
<div className="links">
<Link to={`/forgot-password`}>Forgot Password</Link>
</div>
<button type="submit">Log In</button>
</form>
</div>
......
......@@ -228,13 +228,13 @@
text-align: center;
}
.login {
.login, .forgot-password {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
width: 500px;
height: 350px;
height: 430px;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
box-shadow: 1px 3px 5px rgb(194, 194, 194);
......@@ -250,7 +250,7 @@
align-items: center;
}
.login h1 {
.login h1, .forgot-password h1{
font-size: 40px;
color: #f1356d;
margin-bottom: 20px;
......@@ -258,7 +258,15 @@
align-items: center;
}
.login a {
.login h2, .forgot-password h2{
font-size: 20px;
color: #271a1e;
margin-bottom: 10px;
margin-top: 20px;
align-items: center;
}
.login .links {
font-size: 20px;
color: #35a6f1;
text-decoration: underline;
......@@ -269,7 +277,7 @@
cursor: pointer;
}
.login button {
.login button, .forgot-password button {
background: #f1356d;
color: #fff;
padding: 14px 20px;
......@@ -281,7 +289,7 @@
font-size: 25px;
}
.login input {
.login input, .forgot-password input {
width: 450px;
padding: 12px 20px;
margin: 8px 0;
......@@ -292,7 +300,7 @@
font-size: 15px;
}
.login .button:hover {
.login .button:hover, .forgot-password button:hover {
background: #8f0830;
}
......
......@@ -7,4 +7,5 @@ Flask-Migrate==3.0.1
psycopg2-binary==2.8.6
pytest==6.2.4
pytest-order==0.11.0
bcrypt==3.2.0
\ No newline at end of file
bcrypt==3.2.0
Flask-Mail
\ 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