/
var
/
www
/
vhosts
/
ihelp.ro
/
httpdocs
/
src
/
Model
/
Table
/
/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table
mkdir
upload
Name
Size
Mode
Actions
AppTable.php
2056
0644
edit
dl
rm
AwbsTable.php
7076
0644
edit
dl
rm
BankAccountsTable.php
2622
0644
edit
dl
rm
BannersTable.php
3464
0644
edit
dl
rm
CartProductsTable.php
1752
0644
edit
dl
rm
CartsTable.php
2120
0644
edit
dl
rm
CategoriesTable.php
2599
0644
edit
dl
rm
CauseNewsTable.php
1877
0644
edit
dl
rm
CausesTable.php
3936
0644
edit
dl
rm
CausesTagsTable.php
1450
0644
edit
dl
rm
CitiesTable.php
1909
0644
edit
dl
rm
CountiesTable.php
1186
0644
edit
dl
rm
DocumentsTable.php
2761
0644
edit
dl
rm
DonationsTable.php
2965
0644
edit
dl
rm
GalleryImagesTable.php
11671
0644
edit
dl
rm
LoginTokensTable.php
1486
0644
edit
dl
rm
OrderProductsTable.php
1749
0644
edit
dl
rm
OrdersTable.php
4810
0644
edit
dl
rm
ProductFavoritesTable.php
2255
0644
edit
dl
rm
ProductsTable.php
6987
0644
edit
dl
rm
ProductsTagsTable.php
1466
0644
edit
dl
rm
ProfilesTable.php
3594
0644
edit
dl
rm
ProposedCausesTable.php
1793
0644
edit
dl
rm
SettingsTable.php
1783
0644
edit
dl
rm
SponsorsActivitiesTable.php
3562
0644
edit
dl
rm
SponsorsTable.php
1494
0644
edit
dl
rm
TagsTable.php
906
0644
edit
dl
rm
UserAddressesTable.php
4183
0644
edit
dl
rm
UserSocialsTable.php
783
0644
edit
dl
rm
UsersTable.php
6672
0644
edit
dl
rm
Edit:
/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table/UsersTable.php
(6672B)
<?php declare(strict_types=1); namespace App\Model\Table; use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Table; use Cake\Validation\Validator; use Cake\ORM\TableRegistry; use Cake\Event\EventInterface; use ArrayObject; use Cake\Datasource\EntityInterface; class UsersTable extends AppTable { /** * Initialize method */ public function initialize(array $config): void { parent::initialize($config); $this->setTable('users'); $this->setDisplayField('id'); $this->setPrimaryKey('id'); $this->addBehavior('Timestamp'); $this->belongsTo('Roles', [ 'foreignKey' => 'role_id', 'joinType' => 'INNER', ]); $this->hasMany('Causes', [ 'foreignKey' => 'user_id', ]); $this->hasMany('Messages', [ 'foreignKey' => 'user_id', ]); $this->hasMany('Orders', [ 'foreignKey' => 'user_id', ]); $this->hasMany('PaymentLogs', [ 'foreignKey' => 'user_id', ]); $this->hasMany('ProductFavorites', [ 'foreignKey' => 'user_id', ]); $this->hasMany('Products', [ 'foreignKey' => 'user_id', ]); $this->hasMany('Causes', [ 'foreignKey' => 'user_id', ]); $this->hasOne('Profiles', [ 'foreignKey' => 'user_id', ]); $this->hasMany('UserAddresses', [ 'foreignKey' => 'user_id', ]); } /** * Default validation rules. */ public function validationDefault(Validator $validator): Validator { $validator ->integer('id') ->allowEmptyString('id', null, 'create'); $validator ->email('email') ->requirePresence('email', 'create') ->notEmptyString('email', __('Câmpul este obligatoriu.')); $validator ->scalar('password') ->maxLength('password', 255) ->requirePresence('password', 'create') ->notEmptyString('password', __('Câmpul este obligatoriu.')) ->add('password', 'characters', [ //'rule' => ['custom', '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'], 'rule' => ['custom', '/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/'], 'message' => __('Minim opt caractere, cel puțin o literă și o cifră. Poate conține caractere speciale.'), ]); $validator ->boolean('gdpr_active') ->requirePresence('gdpr_active', 'create') ->notEmptyString('gdpr_active', __('Câmpul este obligatoriu.')) ->equals('gdpr_active', true, __('Câmpul este obligatoriu.')); $validator ->boolean('is_active') ->requirePresence('is_active', null, 'create') ->notEmptyString('is_active'); return $validator; } /** * validationNewPassword */ public function validationNewPassword($validator) { $validator ->scalar('new_password') ->maxLength('new_password', 255) ->requirePresence('new_password', ['create']) ->notEmptyString('new_password', __('Câmpul este obligatoriu.')) ->add('new_password', 'characters', [ //'rule' => ['custom', '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'], 'rule' => ['custom', '/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/'], 'message' => __('Minim opt caractere, cel puțin o literă și o cifră. Poate conține caractere speciale.'), ]); $validator ->requirePresence('confirm_password', 'create') ->notEmptyString('confirm_password', __('Câmpul este obligatoriu.')); $validator->sameAs('confirm_password', 'new_password', 'Parola nu este identică.'); return $validator; } /** * validationResetPassword */ public function validationResetPassword($validator) { $validator ->scalar('password') ->maxLength('password', 255) ->requirePresence('password', ['create']) ->notEmptyString('password', __('Câmpul este obligatoriu.')) ->add('password', 'characters', [ 'rule' => ['custom', '/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/'], 'message' => __('Minim opt caractere, cel puțin o literă și o cifră. Poate conține caractere speciale.'), ]); return $validator; } /** * validationVerifyEmail */ public function validationVerifyEmail($validator) { $validator ->email('email') ->notEmptyString('email', __('Câmpul este obligatoriu.')); $validator ->email('email_send_forgort_password') ->notEmptyString('email_send_forgort_password', __('Câmpul este obligatoriu.')); return $validator; } /** * Used to get user by cookie token */ public function getUserByCookieToken($credentials = array()) { $loginTokenTable = TableRegistry::getTableLocator()->get('LoginTokens'); $userId = $loginTokenTable->getUserIdByCookieToken($credentials); if ($userId) { $user = $this->getUserById($userId); if (!empty($user) && $user['is_active'] && $user['is_email_verified']) { return $user->toArray(); } } return []; } /** * Used to get user by user email */ public function getUserByEmail($email) { if ($email) { $user = $this->find()->where(['Users.email' => $email])->first(); if (!empty($user)) { return $user; } } return []; } /** * Used to get user by user id */ public function getUserById($userId) { if ($userId) { $user = $this->find()->where(['Users.id' => $userId])->contain(['Profiles'])->first(); if (!empty($user)) { return $user; } } return []; } /** * Returns a rules checker object that will be used for validating */ public function buildRules(RulesChecker $rules): RulesChecker { $rules->add($rules->isUnique(['email']), ['errorField' => 'email']); $rules->add($rules->isUnique(['uuid']), ['errorField' => 'uuid']); $rules->add($rules->existsIn(['role_id'], 'Roles'), ['errorField' => 'role_id']); return $rules; } }
Save
cmd:
run