Skip to content

Commit 6eb9ae5

Browse files
committed
Working except login
1 parent a2fd6a2 commit 6eb9ae5

23 files changed

+1012
-611
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
node_modules/
66
database/
7+
db
8+
test
9+
client/assets
710

811
logs
912
*.logs
@@ -20,9 +23,12 @@ client/dist/
2023
.flooignore
2124

2225
.idea/*
26+
links.txt
2327

2428
editor/editor
2529

2630
cert.pem
2731
certMaker
2832
key.pem
33+
Joel.md
34+
Neville.md

certMaker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
var (
31-
host = flag.String("host", "127.0.0.1:8443", "Comma-separated hostnames and IPs to generate a certificate for")
31+
host = flag.String("237919c4.ngrok.io", "98e168f1.ngrok.io", "Comma-separated hostnames and IPs to generate a certificate for")
3232
validFrom = flag.String("start-date", "Mon Jan 6 23:54:57 2017", "Mon Jan 6 15:04:05 2016")
3333
validFor = flag.Duration("duration", 365*24*time.Hour, "Duration that certificate is valid for")
3434
isCA = flag.Bool("ca", true, "whether this cert should be its own Certificate Authority")
@@ -158,4 +158,4 @@ func main() {
158158
pem.Encode(keyOut, pemBlockForKey(priv))
159159
keyOut.Close()
160160
log.Print("written key.pem\n")
161-
}
161+
}

client/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
<head>
44
<meta charset="utf-8">
55
<title>tesis</title>
6-
<!-- Styles -->
7-
<link rel="stylesheet" href="//cdn.quilljs.com/1.1.9/quill.bubble.css">
8-
<link rel="stylesheet" type="text/css" href="client/styles/normalize.css">
9-
<link rel="stylesheet" type="text/css" href="client/styles/style.css">
6+
107
<!-- jquery -->
118
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
129
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
1310
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css" />
1411
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
12+
<!-- Styles -->
13+
<link rel="stylesheet" href="//cdn.quilljs.com/1.1.9/quill.bubble.css">
14+
<link rel="stylesheet" type="text/css" href="client/styles/normalize.css">
15+
<link rel="stylesheet" type="text/css" href="client/styles/style.css">
1516
<!-- end styles -->
1617
</head>
1718
<body>

client/js/auth.js

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import docsave from './docsave.js'
44
import editor from '../js/editor.js'
55

66
Vue.use(VueResource);
7-
8-
const USER_URL = 'https://127.0.0.1:8443';
7+
const PORT = 8443;
8+
// const USER_URL = ' https://98e168f1.ngrok.io';
9+
const USER_URL = `https://${window.location.hostname}:${PORT}`;
910
const eValidate = require('email-validator');
1011
const crypto = require('crypto'),
1112
algorithm = 'aes-256-ctr',
@@ -22,36 +23,57 @@ export default {
2223
signup(context, creds, cb) {
2324
context.$http.post(`${USER_URL}/db/user/signup`, creds)
2425
.then((res) => {
26+
2527
let data = JSON.parse(res.body);
2628
let status = JSON.parse(res.status);
29+
console.log('signup res.body', res.body)
30+
console.log('signup res.status', res.status)
31+
this.user.data = data;
32+
this.user.authenticated = true;
33+
localStorage.setItem('id_token', data.id);
34+
this.jwt(context, data.id);
35+
docsave.getAllDocs(context, data.username);
2736
cb();
2837
})
2938
.catch((err) => {
39+
context.error = true;
3040
context.error = 'This user name already exits!';
3141
});
3242
},
3343

3444
signin(context, creds, cb) {
3545
context.$http.post(`${USER_URL}/db/user/signin`, creds)
3646
.then((res) => {
37-
let data = JSON.parse(res.body);
38-
let status = JSON.parse(res.status);
39-
this.user.data = data;
40-
this.user.authenticated = true;
41-
// Sets token in local storage, this is the only place that
42-
// can set a token, this ensures a falty token can't be set.
43-
localStorage.setItem('id_token', data.id);
44-
this.jwt(context, data.id);
45-
docsave.getAllDocs(context, data.username);
47+
console.log(' \n signin res.body', res.body)
48+
console.log('signin res.status', res.status)
49+
if (res.body !== null) {
50+
this.user.authenticated = true;
51+
let data = JSON.parse(res.body);
52+
this.user.data = data;
53+
localStorage.setItem('id_token', data.id);
54+
this.jwt(context, data.id);
55+
docsave.getAllDocs(context, data.username);
56+
let status = JSON.parse(res.status);
57+
console.log(' \n signin this.user.data', data)
58+
console.log(' \n signin this.user.authenticated', this.user.authenticated)
59+
// Sets token in local storage, this is the only place that
60+
// can set a token, this ensures a falty token can't be set.
61+
console.log('signin docsave', context)
62+
}
63+
64+
4665
})
4766
.catch((err) => {
4867
context.error = true;
68+
console.log('signin context error \n', err, context.error)
4969
});
5070
},
5171

5272
getUser(context, query) {
5373
context.$http.get(`${USER_URL}/db/user`, {params: {'id': query}})
5474
.then((res) => {
75+
console.log('getUser res.body', res.body)
76+
console.log('getUser res.status', res.status)
5577
let data = JSON.parse(res.body);
5678
let status = JSON.parse(res.status);
5779
this.user.data = data[0];

client/js/docsave.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import auth from './auth.js'
22
import editor from '../js/editor.js'
33

4-
const USER_URL = 'https://127.0.0.1:8443';
4+
5+
const PORT = 8443;
6+
const USER_URL = `https://${window.location.hostname}:${PORT}`;
7+
// const USER_URL = ' https://98e168f1.ngrok.io';
58

69
export default {
710
docData: {

client/js/main_content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
// Function opens websocket with unique ID
1818
shareChannel(cb) {
1919
Utils.fetchChannel((response) => {
20-
this.ws = new WebSocket('ws://' + window.location.host + '/ws/' + response.body);
20+
this.ws = new WebSocket('wss://' + window.location.host + '/wss/' + response.body);
2121
// Whenever we receive a message, update textarea
2222
this.ws.onmessage = e => {
2323
// console.log('in this.ws.onmessage',e.data)

0 commit comments

Comments
 (0)