Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
48f632a
Update team members name by alphabetical order
weeyou90 Feb 15, 2018
0b5ca78
Added test function on endpoint (/users/register/)
weeyou90 Feb 15, 2018
e9ab425
Added empty functions for users register, auth, expire, and profile page
weeyou90 Feb 16, 2018
4613093
Initial commit for short answer questions
shannielee Feb 17, 2018
53af746
Initial signup
crazy161 Feb 18, 2018
fa6a992
Added database schema sample code to execute
JasonSia Feb 20, 2018
f781196
GET/Diary
shannielee Feb 21, 2018
ce6bc55
Created an example for posting JSON with flask at diary/create
weeyou90 Feb 21, 2018
4deec45
Merge branch 'master' of ssh://github.com/CS5331-Group-10/rest-api-de…
weeyou90 Feb 21, 2018
0be695b
added db functionality
weeyou90 Feb 22, 2018
2388491
added some simple and incomplete test commands
weeyou90 Feb 22, 2018
946c685
inserted functionality for create, delete, and modify diary entry. no…
weeyou90 Feb 22, 2018
e894800
basic UI, to be further improved
shannielee Feb 22, 2018
ba3f44e
update test script
shannielee Feb 22, 2018
02ba206
Merge branch 'master' of https://github.com/CS5331-Group-10/rest-api-…
shannielee Feb 22, 2018
b9617c3
Implement register and login function, futher need logout function, c…
crazy161 Feb 22, 2018
e3d6330
Implement logout and retrieve infor, further need to add token functi…
crazy161 Feb 22, 2018
312e0dd
added some commments
weeyou90 Feb 23, 2018
90658af
Added Bootstrap css and js
JasonSia Feb 25, 2018
de35d80
Moved all folders
JasonSia Feb 25, 2018
49ca6e4
Merge branch 'master' of ssh://github.com/CS5331-Group-10/rest-api-de…
weeyou90 Feb 25, 2018
83c4cbd
done view diary
weeyou90 Feb 25, 2018
084d2b3
Added bootstrap dependencies
JasonSia Feb 25, 2018
f28a28a
add token function, but need to algin with UI
crazy161 Feb 25, 2018
8f38ce6
wMerge branch 'origin/ethan_021'
weeyou90 Feb 25, 2018
7a1cced
merge UI, first version
crazy161 Feb 25, 2018
863bd6e
Updated ui
JasonSia Feb 25, 2018
07a300a
Merge branch 'ethan_0219' of https://github.com/CS5331-Group-10/rest-…
JasonSia Feb 25, 2018
e2c37bd
Get diary entry
shannielee Feb 25, 2018
e9665bd
Merge with UI, remove email and add token, still need modify API repo…
crazy161 Feb 25, 2018
660d4b1
Updated UI
JasonSia Feb 25, 2018
7d69389
modify info page
crazy161 Feb 25, 2018
e6ccacd
add authorised page
crazy161 Feb 25, 2018
c2901fb
updated UI
JasonSia Feb 25, 2018
201ba35
fix conflict
JasonSia Feb 25, 2018
0190520
Updated unauthorised ui page
JasonSia Feb 25, 2018
8b3f52c
change port back to 8080
crazy161 Feb 25, 2018
c275cab
Merge branch 'ethan_0219' of https://github.com/CS5331-Group-10/rest-…
crazy161 Feb 25, 2018
7432313
merged branch changes
shannielee Feb 25, 2018
a4b575c
merged changes
shannielee Feb 25, 2018
568a853
users view changes
shannielee Feb 25, 2018
d7602dd
linking view and backend for register
shannielee Feb 25, 2018
3828d40
Fixed database not syncing
weeyou90 Feb 25, 2018
9f48f8c
Register and Authenticate should work
weeyou90 Feb 25, 2018
a709985
added new entry page
JasonSia Feb 25, 2018
41f1221
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Feb 25, 2018
de34bd4
Updated new entry
JasonSia Feb 25, 2018
ee2301a
Quick fix for Jason's request, profile is not available for now
crazy161 Feb 25, 2018
a006658
updated new entry ui
JasonSia Feb 25, 2018
7f82c9f
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Feb 25, 2018
40eebbc
profile page link to backend
shannielee Feb 25, 2018
679ae82
Add new entry page
JasonSia Feb 25, 2018
06bdc82
added my entries
JasonSia Feb 25, 2018
15c02cd
add back user_id and auto-increment in a smarter way, add token in se…
crazy161 Feb 25, 2018
1850294
nothing special
crazy161 Feb 26, 2018
fe800d9
updated signup and forms for new entry and my entries
JasonSia Feb 26, 2018
0793a04
Wrote simple tests according to assignment specs
weeyou90 Feb 26, 2018
f103fad
Forgot to add the test files
weeyou90 Feb 26, 2018
e5b2d84
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
crazy161 Feb 26, 2018
6df829b
add front-end function for create diary and user's diary page, need t…
crazy161 Feb 27, 2018
1be7f9b
added buttons for toggling private and public and delete
JasonSia Feb 27, 2018
01d750a
enclose button to form
JasonSia Feb 27, 2018
adb7b9f
move files to html folder
JasonSia Feb 27, 2018
1369fad
Modified register_users according to the test script
weeyou90 Feb 27, 2018
54a09df
Retrieve authenticated user information error response
shannielee Feb 27, 2018
e02b2b9
Fixed backend for authentication
weeyou90 Feb 27, 2018
f7a84ae
retrieve user information
shannielee Feb 27, 2018
179faca
Merge branch 'user-backend' of ssh://github.com/CS5331-Group-10/rest-…
weeyou90 Feb 27, 2018
756558d
refactored index, profile, signup
JasonSia Feb 27, 2018
8fee224
Added login page
JasonSia Feb 27, 2018
9c9ebab
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Feb 27, 2018
266650e
Retrieve authenticated user information
shannielee Feb 27, 2018
2d041e1
Added body on load
JasonSia Feb 27, 2018
a350533
Added functions for expire
weeyou90 Feb 27, 2018
23948a2
Merge branch 'user-backend' of ssh://github.com/CS5331-Group-10/rest-…
weeyou90 Feb 27, 2018
cf4b5a8
(commit to change branch)
weeyou90 Feb 27, 2018
f24ad01
shift the files to the correct location
JasonSia Feb 27, 2018
9e62552
Remove all render_template function, render html from new folder, tes…
crazy161 Feb 27, 2018
6d15d14
fix confilct
crazy161 Feb 27, 2018
0da74e8
Use kill-start.sh to force restart, remove redundant pages
crazy161 Feb 27, 2018
6210512
All backend functionality should work correctly now
weeyou90 Feb 27, 2018
f4771a5
fix register function, check whether user exists
crazy161 Feb 28, 2018
a23bc95
login is successful, but username should be unique in db, token and c…
crazy161 Feb 28, 2018
62dd4a7
Merge branch 'user-backend' into merged_branch
weeyou90 Feb 28, 2018
4d8760a
logout is now available, need to redesign UI
crazy161 Feb 28, 2018
d5011be
Jquery for Authenticate
weeyou90 Feb 28, 2018
dac0a0c
fixing nav bar login status
JasonSia Feb 28, 2018
8902fc1
query user info, can only get response data, also need to fix index
crazy161 Feb 28, 2018
a67d9a4
UI may be a mess, currently user part is almost done but needs improv…
crazy161 Feb 28, 2018
cd702bb
update to nav render
JasonSia Feb 28, 2018
84808d6
merge
JasonSia Feb 28, 2018
147d7de
Fix the navbar to toggle base on user state
JasonSia Feb 28, 2018
df7c468
backend call function for Diary UI
shannielee Feb 28, 2018
33fb352
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
shannielee Feb 28, 2018
602603f
pulled version is not working, fixed the issue with pulled version
shannielee Feb 28, 2018
3309efe
addedLoadDiary but having internal error
JasonSia Feb 28, 2018
0a51b9d
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Feb 28, 2018
48802f2
fixed backend
weeyou90 Feb 28, 2018
ca1ae01
fixed double register bug
weeyou90 Feb 28, 2018
9d16142
demo frontend
weeyou90 Mar 1, 2018
7932fd4
added style to diary
JasonSia Mar 2, 2018
8128c43
fixed modal
JasonSia Mar 3, 2018
8bb4bb4
create new privateDiary file
shannielee Mar 3, 2018
1ca5d6c
change register button id to avoid conflict with login
JasonSia Mar 3, 2018
db35ced
Private Diary page, need to test once the login functionality works
shannielee Mar 3, 2018
5561f4a
added create diary page
JasonSia Mar 3, 2018
65bb43d
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Mar 3, 2018
4b8f706
fix register first
crazy161 Mar 3, 2018
23627e2
Fixed Create Post
JasonSia Mar 3, 2018
5aeae42
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Mar 3, 2018
9146900
Login page now working
shannielee Mar 3, 2018
73980c4
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Mar 3, 2018
06956c9
update logined nav status
JasonSia Mar 3, 2018
cfde5bd
updated nav for signup page
JasonSia Mar 3, 2018
6372d2d
Login and Navbar working
shannielee Mar 3, 2018
2ab80fb
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
shannielee Mar 3, 2018
ed79235
navbar changes
shannielee Mar 3, 2018
e0a0d99
show private diary entries
shannielee Mar 3, 2018
22427ca
mod private diary
JasonSia Mar 3, 2018
b7b593b
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Mar 3, 2018
b33c56f
added icon to edit posts
JasonSia Mar 3, 2018
dff5e79
create diary entry + public and private
shannielee Mar 3, 2018
7e39a8e
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
shannielee Mar 3, 2018
0694237
a
shannielee Mar 3, 2018
5aa559a
private diary entry
shannielee Mar 3, 2018
fd37adf
added icons
JasonSia Mar 3, 2018
53b2687
added clickable css
JasonSia Mar 3, 2018
6521bd7
Modify and delete diary
shannielee Mar 3, 2018
b3add8e
aMerge branch 'merged_branch' of https://github.com/CS5331-Group-10/r…
shannielee Mar 3, 2018
41b8f22
include css file
shannielee Mar 3, 2018
460becb
register, login, profile and logout is fixed
crazy161 Mar 3, 2018
777b643
automerge
crazy161 Mar 3, 2018
65e9028
fix css
JasonSia Mar 3, 2018
307fe7d
Merge branch 'merged_branch' of https://github.com/CS5331-Group-10/re…
JasonSia Mar 3, 2018
9671ec4
test
JasonSia Mar 3, 2018
809e75f
order diary entries based on post timing
shannielee Mar 3, 2018
936c940
readme.md
weeyou90 Mar 3, 2018
6c1a390
Merge branch 'merged_branch' of ssh://github.com/CS5331-Group-10/rest…
weeyou90 Mar 3, 2018
796ae6b
second merge befor final
crazy161 Mar 3, 2018
6aeaa7b
fixed database
weeyou90 Mar 3, 2018
c946865
fixed register error
weeyou90 Mar 3, 2018
0d22b7f
add flask.db
crazy161 Mar 3, 2018
79e078f
updatedNav in profile
JasonSia Mar 3, 2018
b4043fd
clean up codes
shannielee Mar 3, 2018
d3912af
haha
crazy161 Mar 3, 2018
2575406
clean up codes
shannielee Mar 3, 2018
570492f
try to fix invalid inputs
crazy161 Mar 3, 2018
ea2631b
fix create post, but login is still a problem
crazy161 Mar 3, 2018
bb6f7fb
Merge branch 'master' into temp
weeyou90 Mar 3, 2018
a8964b5
Final??? Hopefully!
weeyou90 Mar 3, 2018
4e7896d
literally bugless
weeyou90 Mar 3, 2018
028bf22
Short Answer Questions
shannielee Mar 4, 2018
dfe2484
More answers for short answer questions
shannielee Mar 4, 2018
3c3c058
updated readme
JasonSia Mar 4, 2018
a9b7491
add some screenshots, modify time format in app.py
crazy161 Mar 4, 2018
455ddd1
answered question 3
weeyou90 Mar 5, 2018
f6a3146
Individual Contributions
weeyou90 Mar 5, 2018
9cd1a81
updated readme
JasonSia Mar 5, 2018
d5a41e8
updated readme
JasonSia Mar 5, 2018
d633613
removed trash
weeyou90 Mar 5, 2018
64d4f82
Merge branch 'master' of ssh://github.com/CS5331-Group-10/rest-api-de…
weeyou90 Mar 5, 2018
983bd33
stylo screenshots
weeyou90 Mar 5, 2018
f3a86bf
fixed login bug
weeyou90 Mar 5, 2018
f9bb715
fixed user profile endpoint
weeyou90 Mar 5, 2018
4334a3b
endpoints
weeyou90 Mar 5, 2018
a710cd6
editted json to take in public:true/false
weeyou90 Mar 5, 2018
8704cf3
adjust readme.md
weeyou90 Mar 5, 2018
3900a9e
adjust readme.md
weeyou90 Mar 5, 2018
afc40ee
fixed typos. emptied database
weeyou90 May 14, 2018
f327f00
update port
crazy161 Jan 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
FROM ubuntu:latest
RUN apt-get update
RUN apt-get update
RUN apt-get install -y python-pip
RUN apt-get install -y apache2
RUN pip install -U pip
RUN pip install -U flask
RUN pip install -U flask-cors
RUN apt-get install -y gunicorn
COPY requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install -U setuptools pip wheel && pip install -r /requirements.txt

# RUN pip install -U bcrypt
# RUN pip install -U jinja2
# RUN pip install -U Flask
# RUN pip install -U pip
# RUN pip install -U flask_sqlalchemy
# RUN pip install -U flask-cors
# RUN pip install -U flask_wtf
# RUN pip install -U SQLAlchemy


RUN apt-get install -y sqlite3
RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf
RUN echo "$user hard nproc 20" >> /etc/security/limits.conf
WORKDIR ./src

ADD ./src/service /service
ADD ./src/html /var/www/html
EXPOSE 80
Expand Down
155 changes: 53 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,142 +2,93 @@

CS5331 Assignment 1 Project Reference Repository

## Instructions
## Team Members

Your objective is to implement a web application that provides the endpoints
specified here: https://cs5331-assignments.github.io/rest-api-development/.
1. LAU Wee You
2. LEE Zi Shan
3. SIA Wei Kiat Jason
4. ZHOU Zhi Zhong

The project has been packaged in an easy to set-up docker container with the
skeleton code implemented in Python Flask. You are not restricted in terms of
which language, web stack, or database you desire to use. However, please note
that very limited support can be given to those who decide to veer off the
beaten path.
## Short Answer Questions

You may be required to modify the following files/directories:
### Question 1: Briefly describe the web technology stack used in your implementation.

- Dockerfile - contains the environment setup scripts to ensure a homogenous
development environment
- src/ - contains the front-end code in `html` and the skeleton Flask API code
in `service`
- img/ - contains images used for this README
The application uses Python-Flask to handle requests to the back-end. The code in the Python-Flask will then modify our database using SQLite3.

Assuming you're developing on an Ubuntu 16.04 machine, the quick instructions
to get up and running are:
On the UI, we use javascript to asynchronously call our RESTful API and modify our HTML accordingly.

```
# Install Docker
*****
### Question 2: Are there any security considerations your team thought about?

sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
Yes. However, given that it is not part of the requirements, we have not implemented them.

# Verify Docker Works
Sanitization of inputs should be implemented so that user cannot conduct injection attacks such as SQL-Injection and XSS. For example, without sanitisation, user can write a simple script in a public entry

sudo docker run hello-world
Password protection considerations such as limiting the number of login attempts, password checkers to check for weak passwords.

# Run the skeleton implementation
Enforcing same origin policy to prevent script from another page to obatain data from the current page.

sudo ./run.sh
```
Looked into the possibility of using prepared statements to prevent SQL injection by only allowing specified queries to run.

(Docker CE installation instructions are from this
[link](https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository).)
Filtering all calls to the api first by checking if they are currently login, this will create another layer of barrier from the front end.

**Please consult your assignment hand-out for detailed setup information.**
Implement web certificates so that users can trust that they are heading to the correct site.

## Grading
Session ID might be stolen, as such if possible we would like to tie the session id to the source IP adress and user agent as well.

*****
### Question 3: Are there any improvements you would make to the API specification to improve the security of the web application?

The implementation will be graded in an automated fashion on an Ubuntu 16.04
virtual machine by building the docker container found in your repository and
running it. The grading script will interact with your API.
Use port 80 for both backend and front end so that CORS can be disabled.

The following ports are expected to be accessible:
****
### Question 4: Are there any additional features you would like to highlight?

1. 80, on which static HTML content, including the front-end, is served.
2. 8080, on which the API is exposed.
1) We provide a friendly way to show the diary page, `read more` has a card window to display this diary. modify diary permission and delete personal diaries. Inside `Read My Diary Entries`, we can switch the permission between `public` and `private` through `eye` icon, and delete the page from `delete` icon.

To verify this, please run the following commands:
****
### Question 5: Is your web application vulnerable? If yes, how and why? If not, what measures did you take to secure it?

```
sudo ./run.sh
```

On a different window:
Yes, the web application is vulnerable.
1) There is a chance of leaked session ID. Hence to be more defensive, We store session data such as token on the server side in our Users table. Every login, we will generate a new token and this token will be tagged to the current user for the particular session. For every re-login, we will generate a new token.

2) There is a chance of XSS attack. In our create diary entry page, we placed a script within the Text field such as "<Script>Alert('hello')</ Script>" and we created the diary post, the script was also run. One possible measure is to do a sanity check on what are the inputs being passed from the user to ensure that there are no scripts. Enabling content security policy might help by using a HTTP header to provide a whitelist of sources of trusted content and allow rendering of resources from these sources. In addition there is a possibility of token being stolen due to XSS attacks.

```
curl http://localhost:80
curl http://localhost:8080
```
3) There is a possibility of CSRF attack where the attacker send a forged request on behalf of the victim. In the case of the diary application, a possibile scenario would be the attacker send a request to see the victim's private diary requests or do a public post on behalf of the victim. To increase defense against this, we can do a HTTP referrer validation. By checking the header, we will be able to see if the request is from the same site or cross site, giving the server a better understanding of which site is making the request.

If a response is received, you're good to go.
4) The current application is also susceptible to eavesdropping, as such we can implement HTTPS to prevent man in the middle attack.

**Please replace the details below with information relevant to your team.**
5) Prone to DOS attack, we can implement some services to hold any request from the particlar IP if there is an unusual amount of request from them.

## Screenshots

Please replace the example screenshots with screenshots of your completed
project. Feel free to include more than one.

![Sample Screenshot](./img/samplescreenshot.png)

## Administration and Evaluation

Please fill out this section with details relevant to your team.

### Team Members
6) Brute force attack, we should deny the user from logging in if they have key in more than 3 times of wrong password combination.

1. Member 1 Name
2. Member 2 Name
3. Member 3 Name
4. Member 4 Name

### Short Answer Questions

#### Question 1: Briefly describe the web technology stack used in your implementation.
### Feedback: Is there any other feedback you would like to give?
- Assignment could have been more security focused (For example, given a existing secret diary, implement XXX security features).

Answer: Please replace this sentence with your answer.
## Declaration

#### Question 2: Are there any security considerations your team thought about?
### Please declare your individual contributions to the assignment:

Answer: Please replace this sentence with your answer.
1. LAU Wee You
- Docker requirements, implementing database, skeleton codes, debugging
2. LEE Zi Shan
- Linking front-end and back-end (diary), back-end (diary)
3. SIA Wei Kiat Jason
- Front-end design and implementation, Database Design
4. ZHOU Zhi Zhong
- Linking front-end and back-end (users), back-end (users)

#### Question 3: Are there any improvements you would make to the API specification to improve the security of the web application?

Answer: Please replace this sentence with your answer.

#### Question 4: Are there any additional features you would like to highlight?

Answer: Please replace this sentence with your answer.

#### Question 5: Is your web application vulnerable? If yes, how and why? If not, what measures did you take to secure it?

Answer: Please replace this sentence with your answer.

#### Feedback: Is there any other feedback you would like to give?
## Screenshots

Answer: Please replace this sentence with your answer.
![Create Diary](./img/Create_diary.png)

### Declaration
![Personal Diary Entries](./img/Personal_diary.png)

#### Please declare your individual contributions to the assignment:
![Profile Page](./img/Profile.png)

1. Member 1 Name
- Integrated feature x into component y
- Implemented z
2. Member 2 Name
- Wrote the front-end code
3. Member 3 Name
- Designed the database schema
4. Member 4 Name
- Implemented x
![Public Diary Enntries](./img/Public_diary.png)

Binary file added img/Create_diary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Personal_diary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Public_diary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/samplescreenshot.png
Binary file not shown.
5 changes: 5 additions & 0 deletions kill-restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#/bin/bash

lsof -n -iTCP:80 -sTCP:LISTEN -n -l -P | grep 'LISTEN' | awk '{print $2}' | xargs kill -9
lsof -n -iTCP:8080 -sTCP:LISTEN -n -l -P | grep 'LISTEN' | awk '{print $2}' | xargs kill -9
# sudo ./run.sh
13 changes: 13 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Flask
Flask-SQLAlchemy
Jinja2
SQLAlchemy
Werkzeug
wsgiref
Flask-WTF
alembic
itsdangerous
bcrypt
jinja2
flask-cors
flask_wtf
4 changes: 3 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ if [ "$EUID" -ne 0 ]
exit
fi


TEAMID=`md5sum README.md | cut -d' ' -f 1`
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker build . -t $TEAMID
docker run -p 80:80 -p 8080:8080 -t $TEAMID
docker run -v $(pwd)/src/service/flaskr.db:/service/flaskr.db -p 80:80 -p 8080:8080 -t $TEAMID

98 changes: 98 additions & 0 deletions src/html/createPost.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<html>
<head>
<link href="./css/bootstrap.min.css" rel="stylesheet">
<link href="./css/stylesheet.css" rel="stylesheet">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<script src="./js/demo.js"></script>
<script src="./js/jquery-3.3.1.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/login.js"></script>
</head>
<body onload="userIsLoggedIn();">

<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="./index.html">My Secret Diary</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">

<div id="userNavLeft"></div>
</ul>
<ul class="nav navbar-nav">
<div id="userNavRight"></div>
</ul>

</div>
</nav>
<div class='container jumbo-container'>
<form id ="f" style:"display:hidden">
<label>Title</label>
<input type="text" id="title" class="form-control" style="margin-bottom:10px"></input>

<input type="radio" id="public" name="privacy" value="1"><label for="publicType1"> Public</label>
<input type="radio" id="privacyType2" name="privacy" value="0"><label for="publicType1"> Private</label>

<br>
<label>Text</label>
<textarea type="text" id="text"row="20", style="width:100%; height:300px", class="form-control"></textarea>
<br>
<button class ="btn float-right btn-primary" type="button" id="submitCreate">Create</button>
</div>

</form>

</div>
<script>
$(document).ready(function(){
// click on button submit
$("#submitCreate").on('click', function(e){
console.log('create button clicked')
var title = $("#title").val()
var pub = $("input[name='privacy']:checked").val()
pub = pub==1? true:false
var text = $("#text").val()
tokencookie = getCookie("token");

$.ajax({
url: 'http://localhost:8080/diary/create', // url where to submit the request
type : "POST", // type of action POST || GET
dataType : 'json', // data type
data : JSON.stringify({title:title,public:pub,text:text, token:tokencookie}),
contentType: "application/json",
success : function(data) {

console.log(data.status);
if (data.status == true)
{
alert("Post created!");
window.location= "./privateDiary.html"
}
else
{
alert(data.error);
console.log(data.error)
//window.location= "./login.html";
}

},
error: function(xhr, resp, text) {
console.log(xhr, resp, text);
}
});

});
});

</script>



<script src="./js/jquery-3.3.1.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/login.js"></script>


</body>
</html>
7 changes: 7 additions & 0 deletions src/html/css/bootstrap-grid.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/html/css/bootstrap-grid.min.css.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/html/css/bootstrap-reboot.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/html/css/bootstrap-reboot.min.css.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/html/css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/html/css/bootstrap.min.css.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/html/css/privateDiary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.canClick {
cursor: pointer;
}


.iconsPlacement{
float:right;
}


.eyeMargin{

margin-right: 10px;
}
Loading