Skip to content

Commit

Permalink
fixed auth/mysqli bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Dec 11, 2019
1 parent 83ff10c commit 09d4128
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/core/apiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function validate(array $rules, array $messages = []) {
* @return string, $message: The to add to the errors array
*/
public function returnErrors() {
return $this->form->returnErrors();
return $this->form->errors();
}

public function file_upload($path, $file, $file_category = "image"): Array {
Expand Down
13 changes: 4 additions & 9 deletions src/core/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ public function connect($host, $user, $password, $dbname) {
* @return array user: all user info + tokens + session data
*/
public function basicLogin($username, $password, $password_encode = "md5") {
if ($username == null || $password == null) {
$this->response->respond([
"errors" => "Username and password required"
]);
}
$this->form->validate([
"username" => "validusername",
"password" => "required"
]);
if (!empty($this->form->returnErrors())) {
if (!empty($this->form->errors())) {
$this->response->respond([
"errors" => $this->form->returnErrors()
"errors" => $this->form->errors()
]);
} else {
if ($password_encode == "md5") {
Expand All @@ -70,9 +65,9 @@ public function basicRegister($username, $email, $password, $confirm_password, $
if ($password != $confirm_password) {
$this->form->errors["password"] = "Your passwords don't match";
}
if (!empty($this->form->returnErrors())) {
if (!empty($this->form->errors())) {
$this->response->respond([
"errors" => $this->form->returnErrors()
"errors" => $this->form->errors()
]);
} else {
if ($password_encode == "md5") {
Expand Down
2 changes: 1 addition & 1 deletion src/core/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function validate(array $rules, array $messages = []) {
* @return string, $message: The to add to the errors array
*/
public function returnErrors() {
return $this->form->returnErrors();
return $this->form->errors();
}

/**
Expand Down

0 comments on commit 09d4128

Please sign in to comment.