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

make ChangePasswordController and UI Code respect Message and Hint fr… #1787

Closed
wants to merge 3 commits into from

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Oct 18, 2016

…om HintException

Needed for #1715

Please review @GitHubUser4234 @nickvergessen @ChristophWurst

@blizzz blizzz added this to the Nextcloud 11.0 milestone Oct 18, 2016
@mention-bot
Copy link

@blizzz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MorrisJobke, @rullzer and @michag86 to be potential reviewers.

@blizzz blizzz force-pushed the fix-hintexception-changepasswordcontroller branch from 4bd006f to 948d3d2 Compare October 18, 2016 21:59
if(!_.isEmpty(result.data.hint)) {
message += "<br/>" + _.escape(result.data.hint);
}
OC.Notification.showTemporary(t('admin', message), {isHTML: true});
Copy link
Member

Choose a reason for hiding this comment

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

Just mentioning, when the strings are not used in any other t method, they will not be translated.

Copy link
Contributor

@michag86 michag86 Oct 19, 2016

Choose a reason for hiding this comment

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

Maybe it's better to use t in line 667 and 669?

Copy link
Member Author

Choose a reason for hiding this comment

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

@michag86 this does not help. To make sure that a string is translated, it must be provided as plain text to the method. That way it can be parsed and fed into the translation tool.

Basically I did not change the behavior much. If translation worked before, it is pure luck. This should happen on the server side code where the string is passed (if applicable). Best thing to do here is actually remove the transaltion of received strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the translation call.

@codecov-io
Copy link

codecov-io commented Oct 19, 2016

Current coverage is 57.07% (diff: 60.00%)

Merging #1787 into master will increase coverage by 0.01%

@@             master      #1787   diff @@
==========================================
  Files          1191       1191          
  Lines         71912      71909     -3   
  Methods        7299       7300     +1   
  Messages          0          0          
  Branches       1213       1213          
==========================================
+ Hits          41036      41045     +9   
+ Misses        30876      30864    -12   
  Partials          0          0          
Diff Coverage File Path
•••••• 60% settings/Controller/ChangePasswordController.php

Powered by Codecov. Last update 789e6e7...376d34b

@MorrisJobke
Copy link
Member

MorrisJobke commented Oct 20, 2016

  • Changing the password on the personal page causes this: (it shows the message and the hint(localized))

bildschirmfoto 2016-10-20 um 12 46 41

@MorrisJobke
Copy link
Member

Same for the admin user management (when changing the password of an existing user):

bildschirmfoto 2016-10-20 um 12 48 12

@@ -231,6 +231,9 @@ $(document).ready(function () {
$('#pass2').val('').change();
} else {
if (typeof(data.data) !== "undefined") {
if(!_.isEmpty(data.data.hint)) {
data.data.message += "\n" + data.data.hint;
Copy link
Member

Choose a reason for hiding this comment

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

In normal cases hint is the translated version of message. That is at least the case for all HintExceptions I have seen so far.

@blizzz
Copy link
Member Author

blizzz commented Oct 20, 2016

@MorrisJobke thx.

Wow. After acking through the HintException usages it seems that half of the time the hintparameter is being used as a translated message. Imho that does not make much sense, since this is supposed to be user facing anyway. Also, my perception is that hint should be a suggestion for an action, instead of the reason of the error.

However since it is vastly used in this manner i am hesitating to change this all, and this would include other repos… If this is expected to land into logExpection translated stuff does not make sense again either. Perhaps the best way is to extend (or add another Exception inheriting from it for backwards compatibility) for another parameter, translated message or so 🙈 🙉 🙊

This amazingly extend the PR, resulting in more work than I anticipated. Perhaps I postpone it for a little bit later and we need to go with a workaround solution in #1715 first.

@MorrisJobke
Copy link
Member

@blizzz The hint is the reason that could be shown to the user and is therefore translated. The hint never lands in the logs. The message of an hint exception is untranslated and will never get to the user because it could contain sensitive data. So the usage of the HintException holding the translated string is correct.

cc @LukasReschke

@blizzz
Copy link
Member Author

blizzz commented Oct 21, 2016

@MorrisJobke then we ought to rename the parameter and add some doc. This is confusing and misleading.

@GitHubUser4234
Copy link
Contributor

Yeah, at least adding some comments to the constructor / getHint() method would give a "hint" on how to use them =)

Alright, for the #1715, I'll adjust the code accordingly, thanks @blizzz though 👍

@rullzer
Copy link
Member

rullzer commented Nov 3, 2016

So what are we going to do here? @blizzz @MorrisJobke ?

@MorrisJobke
Copy link
Member

So what are we going to do here? @blizzz @MorrisJobke ?

At least resolve the conflicts :(

@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Nov 18, 2016
@MorrisJobke
Copy link
Member

Needed for #1715

This was already merged in #2286 - how to proceed here?

…om HintException

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
* stings should be translated (if applicable) where they happen
* ChangePasswordController returns all its fixed strings already translated
* local user backend does not throw HintException at all

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@MorrisJobke MorrisJobke force-pushed the fix-hintexception-changepasswordcontroller branch from b97fdcb to 376d34b Compare November 25, 2016 23:03
@MorrisJobke
Copy link
Member

I fixed the conflicts and rebased on master ;)

@blizzz
Copy link
Member Author

blizzz commented Nov 28, 2016

I fixed the conflicts and rebased on master ;)

That's kind, but apart from PHP Doc adjustments there is nothing else to do (cf. #1787 (comment)) I come up with a new PR instead.

@blizzz blizzz closed this Nov 28, 2016
@blizzz blizzz deleted the fix-hintexception-changepasswordcontroller branch November 28, 2016 10:24
@MorrisJobke MorrisJobke removed this from the Nextcloud 12.0 milestone Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants