Example #1
0
 public function checkLoginPassword($login, $password)
 {
     $model = new User();
     $user = $model->findByLogin($login);
     if (!$user) {
         return false;
     } elseif ($user['password'] == md5($password)) {
         return true;
     } else {
         return false;
     }
 }
Example #2
0
     $usertype = $_POST['usertype'];
     $new_user = User::create($login, $password, $usertype);
     if ($new_user == null) {
         header("HTTP/1.0 500 Server Error");
         print "Error creating user.";
         exit;
     } else {
         header("HTTP/1.0 200 Success");
         print "Created new user!";
         exit;
     }
 }
 // Check user (login attempt)
 $login = $_POST['login'];
 $password = $_POST['password'];
 $user_check = User::findByLogin($login);
 if ($user_check == null) {
     header("HTTP/1.0 500 Server Error");
     print "No account with that login exists.";
     exit;
 } else {
     if ($password == $user_check->getPassword()) {
         header("Content-type: application/json");
         print $user_check->getJSON();
         exit;
     } else {
         header("HTTP/1.0 500 Server Error");
         print "We couldn't find that login/password combination in our database.";
         exit;
     }
 }