Example #1
0
 public function createAdmin(\Request $req, \Response $res)
 {
     $admin = new \Model\Admin();
     if ($req->password != $req->confirm_password || !strlen($req->password)) {
         $res->Json(array("flash" => "passwords must have a value and match!"), 500);
         return;
     }
     if (!$admin->checkUsername($req->username) || !strlen($req->username)) {
         $res->Json(array("flash" => "invalid username"), 500);
         return;
     }
     $admin->username = $req->username;
     $admin->email = $req->email;
     if (strlen($req->password)) {
         $admin->password = crypt($req->password);
     }
     $admin->write();
     $res->Json($admin->toArray(array("password")));
 }