Skip to content

Commit

Permalink
Change property name for message in front (text -> message)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenna committed Jan 23, 2017
1 parent a7ce18b commit 40e0287
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 64 deletions.
6 changes: 3 additions & 3 deletions public/scripts/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/scripts/socketMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ socket.on('newMessage', (msgData) => {
chatId: msgData.chatId,
author: msgData.author,
type: msgData.type,
text: msgData.message,
message: msgData.message,
sentAt: msgData.sentAt
};

Expand Down
6 changes: 3 additions & 3 deletions public/views/chatRoom/components/chatRoom.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ChatRoom extends React.Component {
const chatId = data.chatId;
const author = data.author;
const type = data.type;
const text = data.text;
const text = data.message;
const sentAt = data.sentAt;

this.insertNewMessage(chatId, author, type, text, sentAt);
Expand All @@ -56,8 +56,8 @@ class ChatRoom extends React.Component {
this.scrollBottom();
}

insertNewMessage(chatId, author, type, text, sentAt) {
const chatMessage = { author, type, text, sentAt };
insertNewMessage(chatId, author, type, message, sentAt) {
const chatMessage = { author, type, message, sentAt };

const newChat = this.state.chats;
newChat[chatId].messages.push(chatMessage);
Expand Down
4 changes: 2 additions & 2 deletions public/views/chatRoom/components/chatsList/ChatList.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const ChatBox = require('./ChatBox.react');

class ChatList extends React.Component {

static logout() {
logout() {
const expire = new Date().getTime();
document.cookie = `token=;path=/;expires=${expire}`;
location.reload();
}

static hideContactsPanel() {
hideContactsPanel() {
const contactsPanel = document.getElementById('contactsPanel');
contactsPanel.setAttribute('hidden', '');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const React = require('react');

class HeaderContainer extends React.Component {

static openContacts() {
openContacts() {
const contactsPanel = document.getElementById('contactsPanel');
contactsPanel.removeAttribute('hidden');
}
Expand Down
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app.use(express.static(path.join(__dirname, '../public')));

// if inexistant path
app.use((req, res) => {
res.redirect(404, '/views/login');
res.redirect(303, '/views/login');
});

server.listen(process.env.PORT);
Expand Down
49 changes: 23 additions & 26 deletions server/web/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ auth.use(bodyParser.urlencoded({ extended: false }));
auth.use(bodyParser.json());
auth.use(cookieParser());

// // var csrf_guid = Guid.raw();
// const meEndpointBaseUrl = ;
// const tokenExchangeBaseUrl = ;

// Check if user can access chatRoom on request
auth.get('/views', (req, res, next) => {

auth.get('/views/chatRoom', (req, res, next) => {
// Check token cookie
if (req.cookies && req.cookies.token) {

Expand All @@ -31,21 +26,21 @@ auth.get('/views', (req, res, next) => {
return next();
}
res.set('x-authorization', 'Token expired')
.redirect(401, '/views/login');
.redirect(303, '/views/login');


} else {
// No user found or token expired
res.set('x-authorization', 'No user found')
.redirect(401, '/views/login');
.redirect(303, '/views/login');

}
});

} else {
// No cookie token
res.set('x-authorization', 'No token cookie')
.redirect(401, '/views/login');
.redirect(303, '/views/login');
}

});
Expand Down Expand Up @@ -86,30 +81,32 @@ auth.post('/sendcode', (request, response) => {
User.insertUser(id, email, token, expiration);
} else {
// Remove and insert with new data
User.removeUser(id);
User.insertUser(id, email, token, expiration)
.then(() => {

// Set cookie for persistent login session
console.log('setCookie', request.body.code);
response.cookie('token', token, { expires: new Date(expiration) });

// Send user to chatRoom page
response.writeHead(302, {
Location: 'views/chatRoom',
'x-auth': res.data.access_token,
User.removeUser(id).then(() => {
User.insertUser(id, email, token, expiration)
.then(() => {
// Set cookie for persistent login session
response.cookie('token', token, { expires: new Date(expiration) });

// Send user to chatRoom page
response.writeHead(302, {
Location: 'views/chatRoom',
'x-auth': res.data.access_token,
});

response.end();
});

response.end();

}).catch((err) => { throw new Error('Insert user:', err); });
}).catch((err) => { console.log('Find user:', err); });
}
}).catch((err) => { throw new Error('Find user by ID:', err); });
}).catch((err) => { throw new Error('FB /ME ERROR:', err); });
}).catch((err) => { console.log('Find user by ID:', err); });
}).catch((err) => { console.log('FB /ME ERROR:', err); });
}).catch((err) => {
console.log('FB auth:', err);
response.send('Something went wrong.\nSorry, sir.');
});
// if (!response.headersSent) {
// next();
// }
});

module.exports = { auth };
27 changes: 0 additions & 27 deletions telegram.getUpdate

This file was deleted.

0 comments on commit 40e0287

Please sign in to comment.