Merge pull request #25 from seripap/bugfix/usernameWarning

Added warning before changing username
This commit is contained in:
Alan Friedman 2016-02-26 23:42:40 -05:00
commit 16f58684a0
2 changed files with 14 additions and 1 deletions

View File

@ -2,6 +2,9 @@ import _ from 'underscore';
import sanitizeHtml from 'sanitize-html';
import he from 'he';
// TODO: Remove in v2.0
let warned = false;
export default class Chat {
constructor(darkwire, socket) {
this.usernamesInMemory = [];
@ -168,6 +171,7 @@ export default class Chat {
multiple: false,
usage: '/nick {username}',
action: () => {
let newUsername = trigger.params[0] || false;
if (newUsername.toString().length > 16) {
@ -181,6 +185,11 @@ export default class Chat {
return this.log('Username must start with a letter.', {error: true});
}
if (!warned) {
warned = true;
return this.log('Changing your username is currently in beta and your new username will be sent over the wire in plain text, unecrypted. This will be fixed in v2.0. If you really want to do this, type the command again.', {warning: true});
}
this.darkwire.updateUsername(newUsername).then((socketData) => {
let modifiedSocketData = {
username: window.username,

View File

@ -141,7 +141,11 @@ describe('Darkwire', () => {
browser.url('http://localhost:3000/' + testingRoom, () => {
browser.waitForElementPresent('ul.users li:nth-child(2)', 5000, () => {
browser.setValue('textarea.inputMessage', ['/nick rickAnsley', browser.Keys.RETURN], () => {
done();
browser.waitForElementPresent('.log:last-child', 5000, () => {
browser.setValue('textarea.inputMessage', ['/nick rickAnsley', browser.Keys.RETURN], () => {
done();
});
});
});
});
});