完成了保险箱的初始化和访问页面
*功能未实现
This commit is contained in:
parent
6b4e54aff3
commit
555a65ae79
@ -57,7 +57,11 @@ class VaultController extends Controller
|
|||||||
public function actionIndex($directory = null): Response|string
|
public function actionIndex($directory = null): Response|string
|
||||||
{
|
{
|
||||||
$model = Yii::$app->user->identity;
|
$model = Yii::$app->user->identity;
|
||||||
|
if ($model->vault_secret === null) {
|
||||||
|
return $this->render('_init',[
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}//TODO
|
||||||
$rootDataDirectory = Yii::getAlias(Yii::$app->params['dataDirectory']) . '/' . Yii::$app->user->id . '.secret';
|
$rootDataDirectory = Yii::getAlias(Yii::$app->params['dataDirectory']) . '/' . Yii::$app->user->id . '.secret';
|
||||||
|
|
||||||
if ($directory === '.' || $directory == null) {
|
if ($directory === '.' || $directory == null) {
|
||||||
|
@ -29,6 +29,7 @@ use yii\web\IdentityInterface;
|
|||||||
* @property int|null $storage_limit 存储容量限制,MB
|
* @property int|null $storage_limit 存储容量限制,MB
|
||||||
* @property string|null $recovery_codes OTP恢复代码
|
* @property string|null $recovery_codes OTP恢复代码
|
||||||
* @property int|null $dark_mode 夜间模式(0 off,1 on,2 auto)
|
* @property int|null $dark_mode 夜间模式(0 off,1 on,2 auto)
|
||||||
|
* @property string|null $vault_secret 保险箱密钥
|
||||||
*
|
*
|
||||||
* @property CollectionTasks[] $collectionTasks
|
* @property CollectionTasks[] $collectionTasks
|
||||||
* @property Share[] $shares
|
* @property Share[] $shares
|
||||||
@ -44,6 +45,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
public $totp_input; // otp用户输入值
|
public $totp_input; // otp用户输入值
|
||||||
public $recoveryCode_input; // 恢复代码用户输入
|
public $recoveryCode_input; // 恢复代码用户输入
|
||||||
|
|
||||||
|
public $input_vault_secret; // 保险箱密码
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -58,10 +61,10 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['status', 'is_encryption_enabled', 'is_otp_enabled','dark_mode'], 'integer'],
|
[['status', 'is_encryption_enabled', 'is_otp_enabled', 'dark_mode'], 'integer'],
|
||||||
[['created_at', 'last_login'], 'safe'],
|
[['created_at', 'last_login'], 'safe'],
|
||||||
[['bio', 'totp_input','recoveryCode_input','name'], 'string'],
|
[['bio', 'totp_input', 'recoveryCode_input', 'name'], 'string'],
|
||||||
[['encryption_key', 'otp_secret', 'recovery_codes'], 'string', 'max' => 255],
|
[['encryption_key', 'otp_secret', 'recovery_codes', 'vault_secret', 'input_vault_secret'], 'string', 'max' => 255],
|
||||||
[['last_login_ip'], 'string', 'max' => 45],
|
[['last_login_ip'], 'string', 'max' => 45],
|
||||||
[['username', 'password'], 'required', 'on' => 'login'],
|
[['username', 'password'], 'required', 'on' => 'login'],
|
||||||
[['username', 'password', 'email', 'password2'], 'required', 'on' => 'register'],
|
[['username', 'password', 'email', 'password2'], 'required', 'on' => 'register'],
|
||||||
@ -117,7 +120,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
'is_otp_enabled' => 'Is Otp Enabled',
|
'is_otp_enabled' => 'Is Otp Enabled',
|
||||||
'storage_limit' => 'Storage Limit',
|
'storage_limit' => 'Storage Limit',
|
||||||
'recovery_codes' => 'Recovery Codes',
|
'recovery_codes' => 'Recovery Codes',
|
||||||
'dark_mode' =>'Dark Mode'
|
'dark_mode' => 'Dark Mode',
|
||||||
|
'vault_secret' => 'Vault Secret'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
views/vault/_gateway.php
Normal file
28
views/vault/_gateway.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\bootstrap5\Html;
|
||||||
|
use yii\bootstrap5\ActiveForm;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\User $model */
|
||||||
|
/** @var ActiveForm $form */
|
||||||
|
|
||||||
|
$this->title = '解锁文件保险箱';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="vault-gateway">
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>要访问文件保险箱,你必须要提供正确的保险箱密码</p>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
<?= $form->field($model, 'vault_secret')->passwordInput()->label('保险箱密码(不是登陆密码)') ?>
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('确认', ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
28
views/vault/_init.php
Normal file
28
views/vault/_init.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\bootstrap5\Html;
|
||||||
|
use yii\bootstrap5\ActiveForm;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\User $model */
|
||||||
|
/** @var ActiveForm $form */
|
||||||
|
|
||||||
|
$this->title = '初始化文件保险箱';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="vault-init">
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>第一次使用文件保险箱,请在下方输入保险箱密码:</p>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
<?= $form->field($model, 'input_vault_secret')->label('保险箱密码(建议不要与登陆密码相同)')->passwordInput(['autofocus' => true]) ?>
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('初始化保险箱', ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user