Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend password change functionality #57

Merged
merged 1 commit into from
Feb 28, 2016

Conversation

lucyllewy
Copy link

  • refactor clientManager.js to allow configuration parsing as a serparate
    function.
  • refactor clientManager.js to add configuration writing function.
  • add new plugin for /setpass command.
  • add server.js changes to allow for new "profile" screen
  • add password change ui to "profile" screen
  • modify css, front-end shout.js and index.html to add "profile" ui
  • refactor client.js to use new clientManager functionality for saving
    the configuration files

duplicates erming/shout#506

@astorije
Copy link
Member

Hey @diddledan, thanks for this! (Cc @JocelynDelalande as he started reviewing this on Shout)

However, I see that maaaassive diff, I'm a bit scared considering the feature. In particular:

  1. Is there a specific reason why you need to upgrade Bootstrap from 3.2 to 3.5?
  2. I believe the client/index.html.orig file was committed here by accident. Could you confirm and remove please?

I believe once we clean this up a bit it will be much easier to review :-)

@astorije astorije added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Feb 17, 2016
@astorije astorije self-assigned this Feb 17, 2016
@astorije astorije added the Type: Security Security concern or PRs that must be reviewed with extra care regarding security. label Feb 17, 2016
<input class="input" type="password" name="old_password" placeholder="Enter current password">
</div>
<div class="col-sm-12">
<label aria-label="Enter desired new password">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed spaces, use tabs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@JocelynDelalande
Copy link
Contributor

Thanks for careful review (I have to admit reviewing latest commits, I focused on UI), I got my +1 a bit too early on shout project, there is still work to be done, obviously

@diddledan be brave ;-)

@lucyllewy lucyllewy force-pushed the frontend-password-change branch from 237a0e8 to f327a4f Compare February 17, 2016 16:04
@lucyllewy
Copy link
Author

the replaced/upgraded bootstrap was done to add alert-box functionality which was missing from the previous bundle.

@xPaw
Copy link
Member

xPaw commented Feb 17, 2016

Updating bootstrap shouldn't be part of your PR. As for alerts, I'm not fond of how alerts look in bootstrap, maybe using a separate library for the task would be better?

http://kamranahmed.info/toast
https://t4t5.github.io/sweetalert/

Having some alerts like that will come in handy later on when we will handle IRC errors and disconnections (e.g. show an alert when you get disconnected from a network)

@JocelynDelalande
Copy link
Contributor

Updating bootstrap shouldn't be part of your PR.

Depends. As it's motivated, I would be okay with that update to be part of that PR, what do others think ?

BS is (trying to) follow semver, so this version jump is supposed to be backward compatible.

As for alerts, I'm not fond of how alerts look in bootstrap, maybe using a separate library for the task would be better?

http://kamranahmed.info/toast
https://t4t5.github.io/sweetalert/

Having some alerts like that will come in handy later on when we will handle IRC errors and disconnections (e.g. show an alert when you get disconnected from a network)

BS alerts are fine IMHO (I didn't said it's the best), it will still be time to rework alerts later, let's not make things too hard for this PR or it may never make it to master.

@xPaw
Copy link
Member

xPaw commented Feb 17, 2016

Depends. As it's motivated, I would be okay with that update to be part of that PR, what do others think ?

In that case, can we get alerts added to the current bootstrap version to use? Would make for a simpler diff.

@MaxLeiter
Copy link
Member

I think it should be its own PR, or at least a separate commit

@astorije
Copy link
Member

First of all, @diddledan, this is great. I do believe it is not ready at the moment, but I am strongly in favor and will make sure we can get this to a mergeable state.
What is really cool is that the feature itself works, I can indeed change my password from the UI, which is great. This means that while we are striving to make this PR as awesome as we can, people can already run it locally if it's an absolute necessity for their client! And for that I say 👏 👏

Depends. As it's motivated, I would be okay with that update to be part of that PR, what do others think ?

I do not agree with this. Such an upgrade requires testing and therefore should be isolated. As a matter of fact, I noticed the following bug:

Before After
screen shot 2016-02-17 at 22 46 09 screen shot 2016-02-17 at 22 45 50

This bug might not be the upgrade itself, but again by cumulating upgrades, refactors and features, it's very hard for us (at least for me) to see what's wrong in a PR with 1200+ changes.

And while this PR does upgrade Bootstrap from 3.2 to 3.5, as @xPaw stated, it also adds components that were removed using Bootstrap's customized builds, making things a bit harder.

As a matter of fact, if the extra 1k changes are simply to add that dismissible alert-box to display success/failure, I'd say we are doing something wrong.
My proposal is the following:

  • Let's use what we already have accessible in Bootstrap or the custom CSS or whatever so that gets in quickly. At the very least, if nothing can work, we can use a JS alert().
  • In the meantime, we design a notification/alert/flash/whatever-it's-called feature that looks more appropriate for the current design, that can be modified from a theme and that can be re-used by other parts of the project (this is going to be a crucial point in the package system, as such flash container will have its own API there).
  • Then we can update that part of the code when it's ready.
    As @xPaw said, this is not a feature people are going to use every day, so a JS alert(), while definitely ugly and a temporary solution-until-better, does not throw me off. Again, we did not need such feature before, and we are going to reuse it, so let's take the time to design it right.
    What do you think?

@diddledan, a few other things:

  • I noticed the emojis are still there, either because you didn't remove them all in the code, or because you didn't submit the updated grunted templates:
    screen shot 2016-02-17 at 22 54 17
  • This PR also affects tooltips, that do not get hidden well anymore (until a click is emitted somewhere):
    screen shot 2016-02-17 at 22 53 04
  • I am not in favor of adding a "My Profile" element to the menu. There are not many settings at the moment, they need to be designed (not in terms of UI but more broadly) and there is just one element in the profile at the moment. Can you move the password change to the settings instead please? Also, the user icon is already used to display a nick change for now.

That's all I got for now, but I will come back with more once we get to a smaller diff.

Keep up the good work, that's a great start!

@JocelynDelalande
Copy link
Contributor

Thx to everyone for involvement :-)

@astorije showed that bootstrap adhesion to semver rule "no breaking change between two minors" is quite loose, so better be cautious.

As a matter of fact, if the extra 1k changes are simply to add that dismissible alert-box to display success/failure, I'd say we are doing something wrong.
My proposal is the following:

Let's use what we already have accessible in Bootstrap or the custom CSS or whatever so that gets in quickly. At the very least, if nothing can work, we can use a JS alert().

It turns out that there is no need to update bootstrap to get the alerts, it seems to have been present for a while.

Not to over-grow the scope of the PR, nor introduce breaking changes, I'd suggest the following :

  • remove the BS upgrade
  • modify the BS customized build as @xPaw suggested (better in a dedicated commit).

@xPaw @astorije @diddledan ok with that ?

In the meantime, we design a notification/alert/flash/whatever-it's-called feature that looks more appropriate for the current design, that can be modified from a theme and that can be re-used by other parts of the project (this is going to be a crucial point in the package system, as such flash container will have its own API there).
Then we can update that part of the code when it's ready. As @xPaw said, this is not a feature people are going to use every day, so a JS alert(), while definitely ugly and a temporary solution-until-better, does not throw me off. Again, we did not need such feature before, and we are going to reuse it, so let's take the time to design it right. What do you think?

I agree with your 2 stages approach : doing "best-effort" with what we have here, keeping it simple, and designing propper notification later, with global thinking.

@JocelynDelalande
Copy link
Contributor

I am not in favor of adding a "My Profile" element to the menu. There are not many settings at the moment, they need to be designed (not in terms of UI but more broadly) and there is just one element in the profile at the moment. Can you move the password change to the settings instead please? Also, the user icon is already used to display a nick change for now.

Not strongly opinionated on this point. But I'm ok with the proposal to slip it into settings if others are, as it's a common practice, I think users will find it.

@astorije
Copy link
Member

It turns out that there is no need to update bootstrap to get the alerts, it seems to have been present for a while.

I understand alerts have been removed for this very version of Bootstrap 3.2 we are shipping, using the customized build form I have mentioned earlier, which is why @diddledan added them, and which is why I am suggesting a dumb alert() at the moment.

modify the BS customized build as @xPaw suggested (better in a dedicated commit).
@xPaw @astorije @diddledan ok with that ?

I am not ok with this. As said, it's a bigger change that will impact the rest of the features and define some new UI, so it should not be decided as a side-effect of this. Really the alert() way, while the least pretty here, is the simplest and most straightforward/cross-browser solution atm. I am more than ok discussing this right after, but not blindly switching to Bootstrap default alerts without discussion/tests/mockups.

@JocelynDelalande
Copy link
Contributor

I understand alerts have been removed for this very version of Bootstrap 3.2 we are shipping, using the customized build form I have mentioned earlier, which is why @diddledan added them, and which is why I am suggesting a dumb alert() at the moment.

Hm I think there is something I don't understand, let's state what I understand, and stop me where I'm wrong :

  • We are using a slimmed down custom build of bootstrap 3.2
  • This custom build doesn't include alert features
  • Can't we just add the alert feature to the custom build, staying at version 3.2 ?

@astorije
Copy link
Member

We are using a slimmed down custom build of bootstrap 3.2
This custom build doesn't include alert features

Correct.

Can't we just add the alert feature to the custom build, staying at version 3.2 ?

We can, but should not as stated above. alert() is the way to go for this very PR.

@lucyllewy lucyllewy force-pushed the frontend-password-change branch from f327a4f to c3d99a1 Compare February 18, 2016 16:54
@lucyllewy
Copy link
Author

I've reverted the bootstrap, replaced the alerts with the window.alert() function, and moved the ui into settings thereby removing the "profile" page altogether. (the smilie faces should be gone now too!)

@@ -265,6 +265,36 @@ <h1 class="title">Settings</h1>
Enable notification for all messages
</label>
</div>
<% if (!public) { %>
<div id="change-password">
<form action="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add method="post"

@astorije
Copy link
Member

I've reverted the bootstrap, replaced the alerts with the window.alert() function, and moved the ui into settings thereby removing the "profile" page altogether. (the smilie faces should be gone now too!)

Now that's a much nicer diff, I'll do a review when I am outside of work :-)

... Buuuuuut you are going to hate me if not already :-)
I just remember that we already had a feedback for a form (only negative, red feedbak for now, so you could reuse one of the green colors from the UI, if there is no colors set for positive feedback)! It's faaaar from perfect and definitely needs thinking and design, but it's there, and using the same mechanism would allow for more consistency:

screen shot 2016-02-18 at 12 05 14

Again, will make a bigger review later :-)

@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what changed exactly here ? is it github tripping ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like I accidentally saved the file with a UTF-8 BOM identifier. I'll try to remove it in a mo

@lucyllewy lucyllewy force-pushed the frontend-password-change branch from c3d99a1 to e370bdd Compare February 18, 2016 18:08
@@ -46,18 +45,20 @@ var inputs = [
"quit",
"raw",
"services",
"setpass",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to remove this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did. oops :-)

@xPaw
Copy link
Member

xPaw commented Feb 21, 2016

Here's a question: Should the token be re-generated when the password is changed? This would invalidate all sessions, and require them to re-login (re-send new token to current session) with the new password the next time they try to use your account.

@astorije
Copy link
Member

@xPaw, while I fully agree with you, here are my 2 cents:

  • I believe this PR should make it to master without this addition, that we can add later on.
  • I notice this is not the first time you mention something related to the session token. Do you think it would be worth relying on a third-party library for user management, like passport or anything else (if so, we need to list pros/cons to decide)? It seems to do gazillion things we do not need, but I thinking overall. Maybe I am completely wrong, or maybe this is not something we can do short-term, but I'd be happy to have your opinion.

@diddledan, would you mind rebasing with master and fixing what was given in comments (CSS class, labels and setpass) so we can proceed with the reviews? :-)

Thanks a lot for this, and hang in there, it's getting super close!

@xPaw
Copy link
Member

xPaw commented Feb 22, 2016

I notice this is not the first time you mention something related to the session token. Do you think it would be worth relying on a third-party library for user management, like passport or anything else (if so, we need to list pros/cons to decide)? It seems to do gazillion things we do not need, but I thinking overall. Maybe I am completely wrong, or maybe this is not something we can do short-term, but I'd be happy to have your opinion.

That might be worth looking into.

@lucyllewy lucyllewy force-pushed the frontend-password-change branch from 94f1ac6 to 9d6a262 Compare February 22, 2016 12:58
@lucyllewy
Copy link
Author

I believe I've fixed all the issues most-recently raised (sr-only labels, extra "setpass" autocomplete reference now removed, and class names/styles) I've also rebased against master

@@ -734,7 +759,7 @@ $(function() {
});

var windows = $("#windows");
var forms = $("#sign-in, #connect");
var forms = $("#sign-in, #connect, #change-password");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Off-topic of this PR]
I have no idea what's going on here, but this seems fishy. We might want to look into it and its usefulness when we clean up that file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this is used to wire-up the on-submit event handlers on each of the three elements with those IDs, which happen to be <form> elements (the elements are selected separately as there's commas between each ID, and therefore will return a JQuery object referencing each of the elements with IDs sign-in, connect, and change-password). The event handler we wire-up onto this resultant set of elements calls event.preventDefault() which stops the form submittal from reloading the page. The form is submitted through the websocket or XHR instead?

@astorije
Copy link
Member

Hi @diddledan,

When I'm trying to change the password now, I get no success or error message, could you take a look? :-/
Also, Travis CI breaks on CSS linting, do you mind fixing this too?

Not that it will hold off my +1, but I left you a comment in Client.prototype.setPassword, trying to fully understand things.

I should be all set after that :-)

@astorije
Copy link
Member

@YaManicKill, do you mind taking second review after @diddledan has fixed what's currently broken?

@AlMcKinlay
Copy link
Member

Yeah, I'll take a look in the next day or 2.

@astorije
Copy link
Member

Ok, then I think the next minor release (maybe tonight if I have time) will get out without this then. Hopefully @diddledan gets some spare time to put the final touch to this before the next next minor release gets out :-)

  - refactor clientManager.js to allow configuration parsing as a serparate
  function.
  - refactor clientManager.js to add configuration writing function.
  - add server.js changes to allow for new password-change functionality
  - add password change ui to "settings" screen
  - refactor client.js to use new clientManager functionality for saving
    the configuration files
@lucyllewy lucyllewy force-pushed the frontend-password-change branch from 9d6a262 to b79a918 Compare February 26, 2016 18:38
@astorije
Copy link
Member

Alright, excellent work @diddledan, I am finally 👍
👏

Off to a second review now, I don't think it should be blocking as other folks have already taken a look at it!

@xPaw
Copy link
Member

xPaw commented Feb 27, 2016

Looks fine to me code wise.

@maxpoulin64
Copy link
Member

Yep, I think we finally can merge this one. 👍 👏

maxpoulin64 added a commit that referenced this pull request Feb 28, 2016
frontend password change functionality
@maxpoulin64 maxpoulin64 merged commit 1d8667e into thelounge:master Feb 28, 2016
@JocelynDelalande
Copy link
Contributor

Thaaaat is nice, thanks everyone :-), and congrats @diddledan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project. Type: Security Security concern or PRs that must be reviewed with extra care regarding security.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants