/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table
NameSizeModeActions
AppTable.php20560644editdlrm
AwbsTable.php70760644editdlrm
BankAccountsTable.php26220644editdlrm
BannersTable.php34640644editdlrm
CartProductsTable.php17520644editdlrm
CartsTable.php21200644editdlrm
CategoriesTable.php25990644editdlrm
CauseNewsTable.php18770644editdlrm
CausesTable.php39360644editdlrm
CausesTagsTable.php14500644editdlrm
CitiesTable.php19090644editdlrm
CountiesTable.php11860644editdlrm
DocumentsTable.php27610644editdlrm
DonationsTable.php29650644editdlrm
GalleryImagesTable.php116710644editdlrm
LoginTokensTable.php14860644editdlrm
OrderProductsTable.php17490644editdlrm
OrdersTable.php48100644editdlrm
ProductFavoritesTable.php22550644editdlrm
ProductsTable.php69870644editdlrm
ProductsTagsTable.php14660644editdlrm
ProfilesTable.php35940644editdlrm
ProposedCausesTable.php17930644editdlrm
SettingsTable.php17830644editdlrm
SponsorsActivitiesTable.php35620644editdlrm
SponsorsTable.php14940644editdlrm
TagsTable.php9060644editdlrm
UserAddressesTable.php41830644editdlrm
UserSocialsTable.php7830644editdlrm
UsersTable.php66720644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table/UsersTable.php (6672B)
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; } }