Skip to content

Commit

Permalink
Merge pull request phalcon#93 from superrosko/fix/user-active
Browse files Browse the repository at this point in the history
fix: user registration/login and products creation bug
  • Loading branch information
niden authored Nov 29, 2022
2 parents 241acd6 + a2125ad commit d6f649a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Controllers/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function createAction(): void

$form = new ProductsForm();
$product = new Products();
$product->active = '1';

if (!$form->isValid($this->request->getPost(), $product)) {
foreach ($form->getMessages() as $message) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function indexAction(): void
$user->name = $this->request->getPost('name', ['string', 'striptags']);
$user->email = $this->request->getPost('email', 'email');
$user->created_at = new RawValue('now()');
$user->active = 'Y';
$user->active = 1;

if (!$user->save()) {
foreach ($user->getMessages() as $message) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function startAction(): void

/** @var Users $user */
$user = Users::findFirst([
"(email = :email: OR username = :email:) AND password = :password: AND active = 'Y'",
"(email = :email: OR username = :email:) AND password = :password: AND active = 1",
'bind' => [
'email' => $email,
'password' => sha1($password),
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public function initialize()
*/
public function getActiveDetail(): string
{
return $this->active == 'Y' ? 'Yes' : 'No';
return $this->active == 1 ? 'Yes' : 'No';
}
}

0 comments on commit d6f649a

Please sign in to comment.