Skip to content
Permalink
Browse files
  • Loading branch information
czarniek committed Dec 1, 2019
2 parents 2aaa837 + 78aecb2 commit 1544322e8fb0fd7296d810faff49ea560a2bed6f
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 0 deletions.
@@ -186,6 +186,33 @@ router.post('/login', async ctx => {
}
})

router.get('/account', async ctx => {

try {
const userName = ctx.session.userName
const sql = `SELECT id, user, userHash, pass FROM users WHERE userHash = "${userName}"`
const db = await
Database.open(dbName)
const data = await db.all(sql)
await db.close()
await ctx.render('account',{user: data})

} catch (err) {
await ctx.render('error', {message: err.message})
}
})

router.post('/account', koaBody, async ctx => {
try {
const user = await new User(dbName)
await user

} catch (err) {
await ctx.render('error', { message: err.message })
}
})


router.get('/logout', async ctx => {
ctx.session.authorised = null
ctx.redirect('/')
@@ -0,0 +1,201 @@
@charset "UTF-8";
@import url('https://fonts.googleapis.com/css?family=Inconsolata:700');

*{
margin:0;
padding:0;
}
/* hello */
html, body, input[name='fileName'] {
font-family: 'Public Sans', sans-serif;
height: 100%;
position: relative;
color: black;
font-size: 20px;
font-weight: bold;
background: white;
}

body {
min-width: 800px;
width: auto;
}

header {
position: relative;
width: 100%;
height: 130px;
}

#logo {
position: absolute;
left: 30px;
height: 125px;
width: auto;
}

.avatar {
border-radius: 200px;
box-sizing: border-box;
padding: 5px;
background-color: rgb(230, 230, 230);
width: 50px;
height: auto;
}

#nav1{
position: absolute;
top: 50%;
right: 3%;
margin-top: -25px;
}

#nav1 a {
color: white;
vertical-align: middle;
font-size: 14px;
text-decoration: none;
}

#nav1 span {
vertical-align: middle;
margin-left: 5px;

}

#nav1Top {
border-bottom: 1px solid white;
}

#nav1 ul {
width: 95px;
margin: 0;
padding: 0;
position: absolute;
top: 110%;
left: 50%;
margin-left: -55px;
transition: all 0.3s;
visibility: hidden;
opacity: 0;
background-color: #11B8FF;
/* background-color: rgb(230, 230, 230); */
border-radius: 10px 10px 10px 10px;
padding: 0 5px 0 5px;
z-index: 1;
}

#nav1 ul li {
list-style-type: none;
padding: 15px 5px 15px 5px;
}

#nav1:hover ul{
opacity: 1;
visibility: visible;

}

.navImg {
height: 20px;
width: auto;
color: white;
float: left;
vertical-align: middle;
}

#nav2 {
font-size: 22px;
float: left;
border-radius: 0 70px 0 0;
width: 250px;
height: inherit;
background:#11B8FF;
}

#nav2 ul {
margin: 35px 0 0 35px;
padding: 0;
list-style-type: none;

}

#nav2 a {
color: rgb(0, 127, 182);
text-decoration: none;
}

#nav2 a.active {
color: white;
}

#nav2 li {
padding: 20px 0 20px 0;
}

#info {
font-size: 15px;
text-align: center;
}

#UserInformation {
overflow: hidden;
height: inherit;
padding: 40px 80px 0 80px;
}

#tableHead {
display: inline-block;
position: relative;
/* min-width: 380px; */
width: 100%;
}

#tableHead h1 {
font-size: 30px;
float: left;
}

table {
margin-top: 30px;
border-collapse: collapse;
width: 100%;
min-width: 380px;
text-align: left;
vertical-align: middle;
/* height: 100%; */
}

#headRow th{
color: rgb(202, 202, 202);
}

#headRow {
border-bottom: 0px;

}

table tr {
height: 30px;
/* border-bottom: 1px solid gray; */
}

table tr td {
padding: 20px 0 20px 0;
}

.UserName {
width: 10%;
}

.UserID {
width: 5%;
}

.UserHash {
width: 45%;
}

.UserPassword {
width: 5%;
}
@@ -24,6 +24,7 @@
<li> <a href="/myfiles"> Files</a></li>
<li> <a href="#">Contact Us</a></li>
<li> <a href="/logout">Logout</a></li>
<li><a href="/account">Account</a></li>
</ul>

</body>
@@ -23,6 +23,7 @@
<li> <a href="/myfiles"> Files</a></li>
<li> <a href="#">About Us</a></li>
<li> <a href="/logout">Logout</a></li>
<li><a href="/account">Account</a></li>
</ul>

</body>
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accounts page</title>
<link href = "/account.css" type = "text/css" rel = "stylesheet"/>
</head>
<body>
<header>
<a href='/'><img id='logo' src='images/logo.png' alt='Share Drive logo' /></a>
<nav id='nav1'>
<a href=""><img class='avatar'src='images/user.png'/></a>
<ul>
<li id='nav1Top'><a href="#"><img class='navImg'src="images/profile.png"><span>Profile</span></a></li>
<li><a href="/logout"><img class='navImg' src="images/signout.png"><span>Sign out</span></a></li>
</ul>
</nav>
</header>
<nav id='nav2'>
<ul>
<li><a href="/myfiles">My Files</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
</nav>
<section id='UserInformation'>
<section id="tableHead">
<h1>My Files</h1>
<table id='info'>
<tr id='headRow'>
<th class='UserName'>Username</th>
<th class='UserID'>ID</th>
<th class='UserHash'>User hash</th>
<th class='UserPassword'>Password (hashed)</th>
</tr>
{{#each user}}
<tr>
<td class='UserName'>{{this.user}}</td>
<td class='UserID'>{{this.id}}</td>
<td class='UserHash'>{{this.userHash}}</td>
<td class='UserPassword'>{{this.pass}}KB</td>
</tr>
{{/each}}
</table>
</section>
</body>
</html>
@@ -21,6 +21,7 @@
<ul>
<li><a href="/myfiles">My Files</a></li>
<li><a href="/shared">Shared with me</a></li>
<li><a href="/account">Account</a></li>
</ul>
</nav>

@@ -21,6 +21,7 @@
<li><a href="/myfiles">My Files</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact Us</a></li>
<li><a href="/account">Account</a></li>
{{!-- TODO: Change this button to Sign Out when user is logged in --}}
</ul>

@@ -42,6 +42,7 @@
<ul>
<li ><a class='active' href="/myfiles">My Files</a></li>
<li><a href="/shared">Shared with me</a></li>
<li><a href="/account">Account</a></li>
</ul>
</nav>

@@ -35,6 +35,7 @@
<ul>
<li><a href="/myfiles">My Files</a></li>
<li><a href="/shared">Shared with me</a></li>
<li><a href="/account">Account</a></li>
</ul>
</nav>

0 comments on commit 1544322

Please sign in to comment.