registration fix
This commit is contained in:
parent
5cfd591140
commit
eb1abd41e5
@ -138,6 +138,7 @@ class UserCardController extends Controller
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCard();
|
||||
$model->scenario = UserCard::SCENARIO_CREATE_FROM_ADMIN;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
UserCard::generateUserForUserCard($model->id);
|
||||
|
@ -39,7 +39,7 @@ return [
|
||||
'marginBottom' => 5, // Margin bottom pixel
|
||||
'quality' => 95, // JPEG image save quality
|
||||
'transparency' => 70, // Water mark image transparency ( other than PNG )
|
||||
'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
|
||||
//'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
|
||||
'targetMinPixel' => 200 // Target image minimum pixel size
|
||||
]
|
||||
]
|
||||
|
@ -4,7 +4,7 @@
|
||||
/* @var $user common\models\User */
|
||||
|
||||
?>
|
||||
Hello <?= $user->username ?>,
|
||||
<p>Здравствуйте, <b><?= $user->username ?></b></p> ,
|
||||
|
||||
You have successfully registered!
|
||||
Благодорим за регистрацию.
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
/* @var $user common\models\User */
|
||||
|
||||
?>
|
||||
Hello <?= $user->username ?>,
|
||||
Здравствуйте, <?= $user->username ?>,
|
||||
|
||||
You have successfully registered!
|
||||
Благодорим за регистрацию.
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Manager extends \yii\db\ActiveRecord
|
||||
[['user_id'], 'integer'],
|
||||
[['user_id'], 'required'],
|
||||
['user_id', 'unique', 'message' => 'Уже является менеджером'],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -72,4 +72,9 @@ class Status extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->hasMany(UserCard::class, ['status' => 'id']);
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Status::find()->where(['name' => $name])->one()->id ?? false;
|
||||
}
|
||||
}
|
||||
|
@ -240,8 +240,31 @@ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
|
||||
return $this->hasOne(UserCard::class, ['id_user' => 'id']);
|
||||
}
|
||||
|
||||
public function getProjectUser()
|
||||
public function getProjectUser(): \yii\db\ActiveQuery
|
||||
{
|
||||
return $this->hasMany(ProjectUser::class, ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @param int $status
|
||||
* @return UserCard|false
|
||||
*/
|
||||
public static function createSimpleProfile(string $email, int $status = 18): UserCard | bool
|
||||
{
|
||||
$user = User::find()->where(['email' => $email])->one();
|
||||
if ($user) {
|
||||
$profile = new UserCard();
|
||||
$profile->id_user = $user->id;
|
||||
$profile->status = $status;
|
||||
$profile->fio = $email;
|
||||
if ($profile->save()) {
|
||||
return $profile;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
const SCENARIO_UPDATE_RESUME_TEXT = 'update_resume_text';
|
||||
const SCENARIO_DOWNLOAD_RESUME = 'download_resume_text';
|
||||
|
||||
const SCENARIO_CREATE_FROM_ADMIN = 'create_from_admin';
|
||||
|
||||
const AT_PROJECT_BUSY = 1;
|
||||
const AT_PROJECT_FREE = 0;
|
||||
|
||||
@ -114,7 +116,8 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['fio', 'status', 'gender', 'email', 'level', 'position_id'], 'required'],
|
||||
[['fio', 'status', ], 'required'],
|
||||
[['gender', 'email', 'level', 'position_id'], 'required', 'on' => self::SCENARIO_CREATE_FROM_ADMIN],
|
||||
[['gender', 'status', 'position_id', 'id_user', 'level', 'years_of_exp', 'resume_tariff', 'at_project'], 'integer'],
|
||||
[['dob', 'created_at', 'updated_at', 'deleted_at', 'vc_text', 'vc_text_short', 'test_task_getting_date', 'test_task_complete_date'], 'safe'],
|
||||
['email', 'unique', 'message'=>'Почтовый адрес уже используется'],
|
||||
|
@ -13,7 +13,7 @@ class RegistrationEmail extends Email
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->sendTo = $user->email;
|
||||
$this->subject = 'Account registration at ' . Yii::$app->name;
|
||||
$this->subject = 'Регистрация в ' . Yii::$app->name;
|
||||
$this->mailLayout = ['html' => 'signup-html', 'text' => 'signup-text'];
|
||||
$this->params = ['user' => $user];
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"php": ">=8.0",
|
||||
"yiisoft/yii2": "~2.0.6",
|
||||
"yiisoft/yii2-bootstrap": "~2.0.0",
|
||||
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
|
||||
|
@ -5,12 +5,32 @@ namespace console\controllers;
|
||||
|
||||
|
||||
use common\models\Reports;
|
||||
use common\models\User;
|
||||
use common\models\UserCard;
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
|
||||
class SqlController extends Controller
|
||||
{
|
||||
public $email = "";
|
||||
|
||||
/**
|
||||
* @param $actionID
|
||||
* @return string[]
|
||||
*/
|
||||
public function options($actionID)
|
||||
{
|
||||
return ['email'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function optionAliases()
|
||||
{
|
||||
return ['e' => 'email'];
|
||||
}
|
||||
|
||||
public function actionSalary()
|
||||
{
|
||||
$sql = "UPDATE user_card SET salary=REPLACE( `salary`, ' ', '' )";
|
||||
@ -50,4 +70,14 @@ class SqlController extends Controller
|
||||
|
||||
echo "script completed successfully\n";
|
||||
}
|
||||
|
||||
public function actionCreateProfile()
|
||||
{
|
||||
if ($profile = User::createSimpleProfile($this->email, 17)) {
|
||||
echo "Профиль $profile->id успешно создан\n";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "Пользователь $this->email не найден\n";
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
namespace frontend\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\Status;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\User;
|
||||
@ -14,6 +15,7 @@ class SignupForm extends Model
|
||||
public $username;
|
||||
public $email;
|
||||
public $password;
|
||||
public $is_partner = 0;
|
||||
|
||||
|
||||
/**
|
||||
@ -35,6 +37,8 @@ class SignupForm extends Model
|
||||
|
||||
['password', 'required'],
|
||||
['password', 'string', 'min' => 6],
|
||||
|
||||
['is_partner', 'integer']
|
||||
];
|
||||
}
|
||||
|
||||
@ -60,6 +64,8 @@ class SignupForm extends Model
|
||||
$authorRole = $auth->getRole('user');
|
||||
$auth->assign($authorRole, $user->id);
|
||||
|
||||
User::createSimpleProfile($user->email, $this->is_partner ? Status::getByName("Партнер") : Status::getByName("Аутстафинг"));
|
||||
|
||||
return $user->save() ? $user : null;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,11 @@ class RegisterController extends ApiController
|
||||
* type="string",
|
||||
* description="Пароль пользователя",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="is_partner",
|
||||
* type="integer",
|
||||
* description="Является ли пользователь Партнером. Возможные значения 0 или 1. По умолчанию 0",
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
|
Loading…
Reference in New Issue
Block a user