Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Password reset #1989

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions user_saml/ajax/regenerate_password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
*
*/

\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('user_saml');
\OCP\JSON::callCheck();

$l = \OCP\Util::getL10N('user_saml');

$password = \OCP\Util::generateRandomBytes(8);
$username = \OC_User::getUser();

if (\OC_User::setPassword($username, $password)) {
\OCP\JSON::success(array("data" => $password));
} else {
\OC_JSON::error();
}


17 changes: 17 additions & 0 deletions user_saml/js/personalsettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(document).ready(function() {
$('#regenerate_password_button').on( "click", function(){
OC.dialogs.confirm(
t('user_saml', 'Are you sure to reset your desktop client password?'),
t('user_saml', 'Reset desktop client password?'),
function(reset) {
if(reset) {
$.post(OC.filePath('user_saml', 'ajax', 'regenerate_password.php'), "regenerate_password", function(data){
$("#newpassword").text(data.data);
});
}
},
true
);

});
});
45 changes: 45 additions & 0 deletions user_saml/personalsettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* ownCloud - user_saml
*
* @author Szabó Gyula <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/

OC_Util::checkLoggedIn();

$params = array('regenerate_password');

OCP\Util::addscript('user_saml', 'personalsettings');

if ($_POST) {
// CSRF check
OCP\JSON::callCheck();

foreach($params as $param) {
if (isset($_POST[$param])) {
var_dump($param);
}
}
}

// fill template
$tmpl = new OCP\Template( 'user_saml', 'personalsettings');

// settings with default values

return $tmpl->fetchPage();
9 changes: 9 additions & 0 deletions user_saml/templates/personalsettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

<link rel="stylesheet" type="text/css" href="../apps/user_saml/css/saml.css" />
<form class="section" id="regenerate" action="#" method="post">
<h2> <?php p($l->t('Reset desktop client password'));?></h2>
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
<input type="button" id="regenerate_password_button" name="regenerate_password" class="inlineblock" value="<?php p($l->t('Reset'));?>" />
<div class="inlineblock">And your new password is... <strong><span id="newpassword"></span></strong><span id="newpassword_notification"></span></div>
<div><?php p($l->t("Be careful. We will show your new password only once. If you reset it you have to change all syncronizing devices' password."));?></div>
</form>