-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow updating of password on public share #14868
Conversation
- Update password on exisiting share - OCS function updated to call proper function
public static function setPassword($itemType, $itemSource, $password) { | ||
$user = \OC_User::getUser(); | ||
|
||
if ($password == '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
as per code guidelines
* @return boolean | ||
*/ | ||
public static function setPassword($itemType, $itemSource, $password) { | ||
$user = \OC_User::getUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\OCP\IUserSession::getUser
with a check if the user is null and throwing an exception then?
@LukasReschke thanks for the feedback. Most stuff is just the result of copy pasting to get it to work. Cleaning up now. |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): Build result: FAILURE[...truncated 14 lines...] > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10 > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.gitusing GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git422834675921777452.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse refs/remotes/origin/pr/14868/merge^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/pr/14868/merge^{commit} # timeout=10Checking out Revision 18f1443976774ba3422fa512e86fc069ef7bef05 (refs/remotes/origin/pr/14868/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f 18f1443976774ba3422fa512e86fc069ef7bef05 > git rev-list 0b32d578dd3e8076be59703c767f373bfbbe8eaf # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILURESetting status of 3ed3284 to FAILURE with url https://ci.owncloud.org/job/pull-request-analyser-ng-simple/10441/ and message: Merged build finished.Test FAILed. |
* @return boolean | ||
*/ | ||
public static function setPassword($itemType, $itemSource, $password) { | ||
$user = \OC::$server->getUserSession()->getUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For unit test purposes you might want to inject the UserSession as well as the DatabaseConnection in the functions signature.
(obviously not inject it in the public API as that would look ugly - but here it is a valid approach for static code 🙈)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah seems like a good intermediate solution... since rewriting share.php is clearly not in the scope of this PR
@owncloud-bot retest this please |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): Build result: FAILURE[...truncated 14 lines...] > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10 > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.gitusing GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git7563855787991763589.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse refs/remotes/origin/pr/14868/merge^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/pr/14868/merge^{commit} # timeout=10Checking out Revision 838add88badafddb120e24ea4b0bb7d3eac38f63 (refs/remotes/origin/pr/14868/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f 838add88badafddb120e24ea4b0bb7d3eac38f63 > git rev-list 18f1443976774ba3422fa512e86fc069ef7bef05 # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILURESetting status of dfb7542 to FAILURE with url https://ci.owncloud.org/job/pull-request-analyser-ng-simple/10449/ and message: Merged build finished.Test FAILed. |
@owncloud-bot retest this please |
The inspection completed: 7 new issues, 7 updated code elements |
Refer to this link for build results (access rights to CI server needed): |
Please review @schiesbn @PVince81 @LukasReschke @DeepDiver1975 |
* | ||
* @return \Doctrine\DBAL\Query\QueryBuilder | ||
*/ | ||
public function createQueryBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface change, @icewind1991 @DeepDiver1975 @schiesbn I guess we need this anyway ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. as on my todo list to ask more people about this. We somehow need it if we want to support the QueryBuilder or we can't use the IDBConnection to obtain it
Nice one! Originally I was hoping to have a more REST-style API where one must send the whole share model (all values), see #11674 But I think for now we can live with this until we move everything to the OCS Share API. |
@PVince81 I agree. But for now this should be a workable solution. Changing the OCS API is something that probably needs to happen. But that is most likely a slow process. |
Tests
|
Ideally you should also add/update the JS unit tests, see here for an example: https://github.com/owncloud/core/pull/11674/files#diff-760d15f0463b1b3a6ca4b48223badbafR289 |
@PVince81, the reason the second tests fails is because we try to create a new share. I did remove some code at that point. So it is now broken in a different way. Just chaning the ajax call to call setPermissions does not work. Since then a shareWith field is requierd in the code. We cannot provide this since it is often not known. The reason it works in the OCS Api is because there we just fecth all info from a share by the id. The hacks to get this to work properly probably are not pretty. So I suggest to just move that call to the OCS API. Getting the javascript to act nice is probably way easier than hacking the ajax/share.php stuff (and will lead to much duplicated code). Like we already talked about. The new share modal should use more OCS stuff anyways. On a related note, we should really start on cleaning up (or starting over) with lib/private/share/share.php 🙊 |
How about splitting the OCS Share fix from the ajax ones ? At least getting the OCS Share work has higher priority (especially if we intend to move the ajax call to use that too). And in this way the risk of regression will hopefully be lower. What do you think ? |
Yeah that sounds probably best. |
See #14987 for a PR only for the OCS API. Closing this one for now. |
PR to resolve #10671 and #14826 (and possibly others).
currently we cannot update passwords on public shares. What happens is that a new share is created. This leads to problems with the expiration date being not properly propagated and the share getting a new id. Several things have to happen: