mirror of https://github.com/nextcloud/server.git
Use appframework
parent
23ed038a27
commit
a7fbd91e53
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Victor Dubiniuk
|
||||
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OC\Core\LostPassword;
|
||||
|
||||
class AjaxController {
|
||||
public static function lost() {
|
||||
\OCP\JSON::callCheck();
|
||||
|
||||
try {
|
||||
Controller::sendEmail(@$_POST['user'], @$_POST['proceed']);
|
||||
\OCP\JSON::success();
|
||||
} catch (EncryptedDataException $e){
|
||||
\OCP\JSON::error(
|
||||
array('encryption' => '1')
|
||||
);
|
||||
} catch (\Exception $e){
|
||||
\OCP\JSON::error(
|
||||
array('msg'=> $e->getMessage())
|
||||
);
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function resetPassword($args) {
|
||||
\OCP\JSON::callCheck();
|
||||
try {
|
||||
Controller::resetPassword($args);
|
||||
\OCP\JSON::success();
|
||||
} catch (Exception $e){
|
||||
\OCP\JSON::error(
|
||||
array('msg'=> $e->getMessage())
|
||||
);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OC\Core\LostPassword\Controller;
|
||||
|
||||
use \OCP\AppFramework\Controller;
|
||||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
class LostController extends Controller {
|
||||
|
||||
protected $urlGenerator;
|
||||
|
||||
public function __construct($appName, IRequest $request, IURLGenerator $urlGenerator) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function reset() {
|
||||
// Someone wants to reset their password:
|
||||
if($this->checkToken()) {
|
||||
return new TemplateResponse(
|
||||
'core/lostpassword',
|
||||
'resetpassword',
|
||||
array(
|
||||
'link' => $link
|
||||
),
|
||||
'guest'
|
||||
);
|
||||
} else {
|
||||
// Someone lost their password
|
||||
$isEncrypted = \OC_App::isEnabled('files_encryption');
|
||||
return new TemplateResponse(
|
||||
'core/lostpassword',
|
||||
'lostpassword',
|
||||
array(
|
||||
'isEncrypted' => $isEncrypted,
|
||||
'link' => $this->getResetPasswordLink()
|
||||
),
|
||||
'guest'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getResetPasswordLink(){
|
||||
$parameters = array(
|
||||
'token' => $this->params('token'),
|
||||
'user' => $this->params('user')
|
||||
);
|
||||
$link = $this->urlGenerator->linkToRoute('core.ajax.reset', $parameters);
|
||||
return $this->urlGenerator->getAbsoluteUrl($link);
|
||||
}
|
||||
|
||||
protected function checkToken() {
|
||||
$user = $this->params('user');
|
||||
$token = $this->params('token');
|
||||
return \OC_Preferences::getValue($user, 'owncloud', 'lostpassword') === hash('sha256', $token);
|
||||
}
|
||||
}
|
@ -1,35 +1,20 @@
|
||||
<?php
|
||||
//load the file we need
|
||||
OCP\Util::addStyle('lostpassword', 'lostpassword');
|
||||
if ($_['requested']): ?>
|
||||
<div class="update"><p>
|
||||
<?php
|
||||
print_unescaped($l->t('The link to reset your password has been sent to your email.<br>If you do not receive it within a reasonable amount of time, check your spam/junk folders.<br>If it is not there ask your local administrator .'));
|
||||
?>
|
||||
</p></div>
|
||||
<?php else: ?>
|
||||
<form action="<?php //print_unescaped(OC_Helper::linkToRoute('core_lostpassword_send_email')) ?>" method="post">
|
||||
<fieldset>
|
||||
<?php if ($_['error']): ?>
|
||||
<div class="error"><p>
|
||||
<?php print_unescaped($l->t('Request failed!<br>Did you make sure your email/username was right?')); ?>
|
||||
</p></div>
|
||||
<?php endif; ?>
|
||||
<div class="update"><?php print_unescaped($l->t('You will receive a link to reset your password via Email.')); ?></div>
|
||||
<p>
|
||||
<input type="text" name="user" id="user"
|
||||
placeholder="<?php print_unescaped($l->t( 'Username' )); ?>"
|
||||
value="" autocomplete="off" required autofocus />
|
||||
<label for="user" class="infield"><?php print_unescaped($l->t( 'Username' )); ?></label>
|
||||
<img class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/>
|
||||
<?php if ($_['isEncrypted']): ?>
|
||||
OCP\Util::addStyle('lostpassword', 'lostpassword'); ?>
|
||||
<form action="<?php print_unescaped($_['link']) ?>" method="post">
|
||||
<fieldset>
|
||||
<div class="update"><?php print_unescaped($l->t('You will receive a link to reset your password via Email.')); ?></div>
|
||||
<p>
|
||||
<input type="text" name="user" id="user" placeholder="<?php print_unescaped($l->t( 'Username' )); ?>" value="" autocomplete="off" required autofocus />
|
||||
<label for="user" class="infield"><?php print_unescaped($l->t( 'Username' )); ?></label>
|
||||
<img class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/>
|
||||
<?php if ($_['isEncrypted']): ?>
|
||||
<br />
|
||||
<p class="warning"><?php print_unescaped($l->t("Your files are encrypted. If you haven't enabled the recovery key, there will be no way to get your data back after your password is reset. If you are not sure what to do, please contact your administrator before you continue. Do you really want to continue?")); ?><br />
|
||||
<input type="checkbox" name="continue" value="Yes" />
|
||||
<?php print_unescaped($l->t('Yes, I really want to reset my password now')); ?></p>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<input type="submit" id="submit" value="<?php print_unescaped($l->t('Reset')); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php print_unescaped($l->t('Yes, I really want to reset my password now')); ?></p>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<input type="submit" id="submit" value="<?php print_unescaped($l->t('Reset')); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -1,16 +1,9 @@
|
||||
<form action="<?php print_unescaped(OC_Helper::linkToRoute('core_lostpassword_reset', $_['args'])) ?>" method="post">
|
||||
<form action="<?php print_unescaped($_['link']) ?>" method="post">
|
||||
<fieldset>
|
||||
<?php if($_['success']): ?>
|
||||
<h1><?php p($l->t('Your password was reset')); ?></h1>
|
||||
<p><a href="<?php print_unescaped(OC_Helper::linkTo('', 'index.php')) ?>/"><?php p($l->t('To login page')); ?></a></p>
|
||||
<?php else: ?>
|
||||
<p>
|
||||
<label for="password" class="infield"><?php p($l->t('New password')); ?></label>
|
||||
<input type="password" name="password" id="password"
|
||||
placeholder="<?php p($l->t('New password')); ?>"
|
||||
value="" required />
|
||||
</p>
|
||||
<input type="submit" id="submit" value="<?php p($l->t('Reset password')); ?>" />
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
<label for="password" class="infield"><?php p($l->t('New password')); ?></label>
|
||||
<input type="password" name="password" id="password" value="" required />
|
||||
</p>
|
||||
<input type="submit" id="submit" value="<?php p($l->t('Reset password')); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue