Skip to content
Snippets Groups Projects
Commit 5e4900f0 authored by Arianne Bayliss's avatar Arianne Bayliss
Browse files

Merge branch '2-as-a-user-i-want-to-be-authorized-if-i-am-a-member' into 'development'

Resolve "As a user I want to be authorized if I am a member"

Closes #2

See merge request !60
parents eeda094a 964a02c5
No related branches found
No related tags found
1 merge request!60Resolve "As a user I want to be authorized if I am a member"
......@@ -11,9 +11,15 @@ CREATE TABLE IF NOT EXISTS "coworking_spaces" (
"Opening_Hours" TEXT,
"Checkin_Instructions" TEXT
);
CREATE TABLE IF NOT EXISTS "login" (
"Email" TEXT PRIMARY KEY NOT NULL,
"Password" TEXT NOT NULL
);
INSERT INTO "coworking_spaces" VALUES ('Codebase','CodeBase Edinburgh , 37a Castle Terrace, Edinburgh, EH1 2EL','https://images.squarespace-cdn.com/content/v1/55439320e4b0f92b5d6c4c8b/1646867535415-4JI39H286BUMT26H4FHN/C36A1915.jpg?format=2500w','https://images.squarespace-cdn.com/content/v1/55439320e4b0f92b5d6c4c8b/1646868533510-J1OT4PEG5VM9FCBF8BJE/15.10.19_-_CREATIVE_BRIDGE_C02_-_DAY01_-_LQ-19+%281%29.jpg?format=2500w,https://images.squarespace-cdn.com/content/v1/55439320e4b0f92b5d6c4c8b/1646868421127-07KQ4N1OHTDDKQME686A/15.10.19_-_CREATIVE_BRIDGE_C02_-_DAY01_-_LQ-52+%281%29.jpg?format=2500w','Hi. We’re CodeBase. We''ve been exploring the world of startups and innovation for over five years now. We''re not really sure how to best describe what we do, but we think the words "tech cluster" probably do it best. Please get in touch! We’re friendly people who are geeky about building tech startups, managing disruption and innovation.','https://www.thisiscodebase.com','info@thisiscodebase.com','(+44) 0131 560 2003','08:00 - 17:00','Use the email address or phone number to call ahead and book a desk, let them know you''re a Tramshed member');
INSERT INTO "coworking_spaces" VALUES ('Catalyst','Titanic Quarter, Queens Road, Belfast, BT3 9DT','https://wearecatalyst.org/wp-content/uploads/2022/05/Catalyst03.jpg','https://wearecatalyst.org/wp-content/uploads/2022/03/DSC07673-scaled-2048x1570.jpg,https://wearecatalyst.org/wp-content/uploads/2021/01/2F6A1513.jpg','We are an independent, not-for-profit organisation working together for the greater good, enabling a connected community of like-minded innovators in an entrepreneurial eco-system that is the key driver of the knowledge economy in Northern Ireland.','https://wearecatalyst.org','enquiries@wearecatalyst.org','+44(0)28 9073 7800','08:00 - 18:00','Use the email address or phone number to call ahead and book a desk, let them know you''re a Tramshed member');
INSERT INTO "coworking_spaces" VALUES ('C4DI','C4DI Campus, 31-38 Queen Street, Hull, HU1 1UU','https://images.squarespace-cdn.com/content/v1/5709040420c647579532dbb4/1594914119071-OWI9G22S295OCMSWL0VL/_K5L1162.jpg?format=2500w','https://images.squarespace-cdn.com/content/v1/5709040420c647579532dbb4/1588346951023-V0QWKQI35IDUACMOJ0WM/_MKL2718.jpg?format=750w,https://images.squarespace-cdn.com/content/v1/5709040420c647579532dbb4/1588346977833-LGY6P9473H2C5JF6I2UG/_K5M5505.jpg?format=750w','C4DI is an incubator that helps tech companies grow, and traditional businesses innovate.','http://www.c4di.co.uk','lc@c4di.net','+44 1482 304244','9am - 5pm','Use the email address or phone number to call ahead and book a desk, let them know you''re a Tramshed member');
INSERT INTO "coworking_spaces" VALUES ('Dogpatch Labs','Custom House Quay, Dublin, D01 Y6H7','https://dogpatchlabs.wpenginepowered.com/wp-content/uploads/2022/09/ian_browne.jpg','https://dogpatchlabs.wpenginepowered.com/wp-content/uploads/2021/07/bordered.jpg,https://dogpatchlabs.com/wp-content/uploads/2020/03/UG_3-1.jpg','Dogpatch Labs is a startup hub, located in the heart of Dublin’s Digital Docklands.','https://dogpatchlabs.com','info@dogpatchlabs.com',NULL,'8:30 - 5:30','Use the email address or phone number to call ahead and book a desk, let them know you''re a Tramshed member');
INSERT INTO "coworking_spaces" VALUES ('Stafion F','5 Parvis Alan Turing, Paris','https://stationf.co/img/misc/create-zone.jpg',',https://stationf.co/img/flatmates/coffee-restaurant.jpg','Based in central Paris, STATION F gathers a whole entrepreneurial ecosystem under one roof. We help entrepreneurs bring their ambitious ideas to life.','https://stationf.co',NULL,NULL,'0:00 - 0:00','Book through the Tramshed Tech app');
INSERT INTO "coworking_spaces" VALUES ('Station F','5 Parvis Alan Turing, Paris','https://stationf.co/img/misc/create-zone.jpg',',https://stationf.co/img/flatmates/coffee-restaurant.jpg','Based in central Paris, STATION F gathers a whole entrepreneurial ecosystem under one roof. We help entrepreneurs bring their ambitious ideas to life.','https://stationf.co',NULL,NULL,'0:00 - 0:00','Book through the Tramshed Tech app');
COMMIT;
......@@ -18,6 +18,10 @@ def connect_db(db_file=DATABASE):
print("Error connecting to database.")
return conn
@app.route("/home", methods=["GET"])
def load():
return render_template('landingpage.html')
@app.route("/", methods=['GET'])
def returnIndex():
if (request.method == 'GET'):
......@@ -209,7 +213,33 @@ def Locations():
return render_template('locations.html')
@app.route("/login", methods=["GET"])
def loadlogin():
return render_template('login.html')
@app.route("/signin", methods=['GET', 'POST'])
def login():
error = None
if (request.method =='POST'):
recordEmail = request.form.get('recordEmail')
print(recordEmail)
recordPassword = request.form.get('recordPassword')
print(recordPassword)
try:
conn = sqlite3.connect(DATABASE)
cur = conn.cursor()
cur.execute("INSERT INTO login ('Email','Password') values (?,?)", (recordEmail, recordPassword))
conn.commit()
recordData = cur.fetchall()
print(recordData)
return recordData
except Exception as e:
recordData = e
print(f"Error: {e}")
conn.close()
finally:
conn.close()
return render_template('locations.html')
if __name__ == "__main__":
......
......@@ -22,8 +22,4 @@ body{
font-family: 'Sora', sans-serif;
background-color: #212529;
color: white;
<<<<<<< HEAD
}
=======
}
>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239
function onLoad() {
document.getElementById('loginButton').addEventListener('click', AddRecord)
}
function AddRecord(e) {
e.preventDefault();
e.stopPropagation();
var recordEmail = document.getElementById("recordEmail").value;
var recordPassword = document.getElementById("recordPassword").value;
var params = 'recordEmail='+recordEmail+'&recordPassword='+recordPassword;
var xhttp = new XMLHttpRequest();
xhttp.open("POST", '/AddRecord', true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.onreadystatechange = function() {
if (xhttp.readyState === 4 && xhttp.status === 200) {
console.log(xhttp.responseText);
serverResponse = JSON.parse(xhttp.responseText);
document.getElementById("recordEmail").value = serverResponse[0][0];
document.getElementById("recordPassword").value = serverResponse[0][1];
document.getElementById("DEBUGserverMessage").innerHTML = xhttp.responseText;
} else {
console.error(`Status Text: ${xhttp.statusText}.`);
console.error(`Ready State: ${xhttp.readyState}.`);
}
};
xhttp.send(params);
}
......@@ -9,18 +9,21 @@
<div class="container-fluid">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="locations.html">Coworking locations</a>
<a class="nav-link" href="/locations">Coworking locations</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Manage_Coworking_Spaces">Manage locations</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/login">Login</a>
</li>
</ul>
</div>
</nav>
</header>
<header class="masthead bg-dark text-white text-left">
<div class="container-fluid">
<img id="logo" src="Media/logo.png"/>
<img id="logo" src="static/Media/logo.png"/>
<h1 id="header">Tramshed Tech</h1>
</div>
</header>
......@@ -31,9 +34,9 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="CSS/landingstyle.css">
<link rel="stylesheet" href="static/CSS/landingstyle.css">
<title>Tramshed Tech</title>
<img id="tramshed" src="Media/tramshed.jpg">
<img id="tramshed" src="static/Media/tramshed.jpg">
<div class="bg-dark p-3">
<div id="buttons" class="flex-container">
<button onclick="window.location.href='locations.html';" type="button" class="btn btn-light">
......
......@@ -3,9 +3,18 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container-fluid">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/home">Back</a>
</li>
</ul>
</div>
</nav>
<header class="masthead bg-dark text-white text-center">
<div class="container-fluid">
<img id="logo" src="Media/logo.png"/>
<img id="logo" src="static/Media/logo.png"/>
<h1 id="header">Tramshed Tech</h1>
</div>
</header>
......@@ -16,60 +25,31 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="CSS/loginstyle.css">
<link rel="stylesheet" href="static/CSS/loginstyle.css">
<script src="static/JS/login.js"></script>
<title>Login</title>
<div id="card" class="card text-dark w-25 text-center">
<div class="card-body text-center">
<form>
<form action="/signin" method="post">
<!-- Email input -->
<div class="form-outline mb-4">
<<<<<<< HEAD
<input type="email" id="recordEmail" class="form-control" />
=======
<input type="email" id="form2Example1" class="form-control" />
>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239
<label class="form-label" for="form2Example1">Email address</label>
<input type="email" name="recordEmail" id="recordEmail" class="form-control" />
<label class="form-label">Email address</label>
</div>
<!-- Password input -->
<div class="form-outline mb-4">
<<<<<<< HEAD
<input type="password" id="recordPassword" class="form-control" />
=======
<input type="password" id="form2Example2" class="form-control" />
>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239
<label class="form-label" for="form2Example2">Password</label>
</div>
<!-- 2 column grid layout for inline styling -->
<div class="row mb-4">
<div class="col d-flex justify-content-center">
<!-- Checkbox -->
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="form2Example31" checked />
<label class="form-check-label" for="form2Example31"> Remember me </label>
</div>
</div>
<div class="col">
<!-- Simple link -->
<a href="#!">Forgot password?</a>
<input type="password" name="recordPassword" id="recordPassword" class="form-control" />
<label class="form-label">Password</label>
</div>
<!-- Submit button -->
<button onclick="window.location.href='landingpage.html';" type="button" class="btn btn-light">
<button type="submit" class="btn btn-light" id="loginButton" href="/locations">
<span class="spinner-grow spinner-grow-sm"></span>
Sign in
</button>
<!-- Register buttons -->
<div class="text-center">
<p>Not a member? <a href="#!">Register</a></p>
</form>
</body>
<<<<<<< HEAD
</html>
=======
</html>
>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239
File moved
import os
import sqlite3
from flask import Flask, redirect, request, render_template, jsonify
from flask import Flask, request, render_template, send_from_directory
app = Flask(__name__)
DATABASE = "login.db"
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
@app.route("/SearchRecord", methods=['POST'])
def searchRecord():
@app.route("/home", methods=["GET"])
def load():
return render_template('landingpage.html')
if request.method =='POST':
@app.route("/locations", methods=["GET"])
def loadlocations():
return send_from_directory('static', 'locations.html')
@app.route("/coworking", methods=["GET"])
def loadcoworking():
return render_template('manage_coworking_spaces.html')
@app.route("/login", methods=["GET"])
def loadlogin():
return render_template('login.html')
@app.route("/signin", methods=['GET', 'POST'])
def login():
error = None
if (request.method =='POST'):
recordEmail = request.form.get('recordEmail')
print(recordEmail)
recordPassword = request.form.get('recordPassword')
print(recordPassword)
try:
recordEmail = request.form.get('recordEmail', default="Error")
conn = sqlite3.connect(DATABASE)
cur = conn.cursor()
cur.execute("SELECT * FROM login WHERE Email=?;", [recordEmail])
recordData = cur.fetchall()
except:
print(f"Error: {recordData}")
conn.close()
conn = sqlite3.connect("login.db")
cur = conn.cursor()
cur.execute("INSERT INTO login ('Email','Password') values (?,?)", (recordEmail, recordPassword))
conn.commit()
recordData = cur.fetchall()
print(recordData)
return recordData
except Exception as e:
recordData = e
print(f"Error: {e}")
conn.close()
finally:
conn.close()
print(f"{str(recordData)} Record found.")
return str(recordData)
@app.route("/AddRecord", methods=['POST'])
def addRecord():
if (request.method == 'POST'):
recordEmail = request.form['recordEmail']
recordPassword = request.form['recordPassword']
conn = sqlite3.connect(DATABASE)
cur = conn.cursor()
cur.execute("INSERT INTO login ('Email', 'Password')\
VALUES (?,?)", (recordEmail, recordPassword))
conn.commit()
conn.close()
infoMessage = (f'{recordData} Record added.')
print(infoMessage)
return (infoMessage)
conn.close()
return render_template('locations.html')
if __name__ == "__main__":
app.run(debug=True)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment