public function doPost() { $r = UsuarioResource::getInstance(); $usuario = Usuario::fromArray($r->getRequest()); if ($usuario->getEmail()) { if ($usuario->getSenha()) { if ($usuario->getUsername()) { $m = UsuarioController::cadastrar($usuario); if ($m) { created_header(); echo $usuario->getJson("nome,username,email,codigo"); } else { exception_header(); UsuarioController::print_exception("cadastrar"); } } else { bad_request_header(); } } else { UsuarioController::porEmail($usuario->getEmail()); ok_header(); if (UsuarioController::get("id")) { echo UsuarioController::$usuario->getJson("id,nome,username,email,codigo,status,departamento"); } else { echo $usuario->getJson("email"); } } } else { bad_request_header(); } }
function confirmar_recebimento_de_solicitacao() { $s = "<h2>Ativar conta de usuário do SLAST</h2>"; $s .= "<h3>Sobre sua conta</h3>"; $s .= "<p><strong>Nome: </strong>" . UsuarioController::get("nome") . "</p>"; $s .= "<p><strong>Login: </strong>" . UsuarioController::get("username") . "</p>"; $s .= "<p><strong>Código para ativação: </strong><span style=\"color:red\">" . UsuarioController::get("codigo") . "</span></p>"; echo $s; }
public function doPost() { $r = UsuarioResource::getInstance(); if ($r->getRequest("username")) { UsuarioController::porUsername($r->getRequest("username")); ok_header(); if (!UsuarioController::get("id")) { UsuarioController::set("username", $r->getRequest("username")); } echo UsuarioController::$usuario->getJson("id,nome,username,email,codigo,status,departamento"); } else { bad_request_header(); } }
<?php require "../app/project.php"; ?> <?php getController("Usuario"); getController("Sessao"); getController("Departamento"); ?> <?php if (isset($_COOKIE["credentials"])) { SessaoController::autenticar($_COOKIE["credentials"]); } if (UsuarioController::get("id")) { $o = UsuarioController::podeCriarDepartamentos(); if ($o) { ok_header(); echo UsuarioController::$usuario->getJson("id,username"); } else { exception_header(); echo "Usuário sem permissão para cadastrar departamentos"; } } else { unauthorized_header(); }
public static function iniciar() { $s = SessaoController::porUsuario(); if ($s) { if ($s->getSize() <= 3) { if ($s->getSize() == 3) { $s1 = Sessao::fromArray($s->getElement(0)); $s1->setCodigo(UsuarioController::get("codigo")); $o = $s1->refresh(); if ($o) { SessaoController::gerar_token(); } } else { self::$sessao->setUsuario(UsuarioController::get("id")); self::$sessao->setCodigo(UsuarioController::get("codigo")); $o = self::$sessao->persistir(); if ($o) { SessaoController::gerar_token(); } } } } }
public static function cadastrar(Usuario $u) { UsuarioController::porEmail($u->getEmail()); if (UsuarioController::get("id")) { $e = "E-mail já cadastrado."; UsuarioController::defineException("cadastrar", $e); } else { UsuarioController::porUsername($u->getUsername()); if (UsuarioController::get("id")) { $e = "Nome de usuário já utilizado."; UsuarioController::defineException("cadastrar", $e); } else { require_once PROJECT_ADDRESS . "/lib/util/code.php"; require_once PROJECT_ADDRESS . "/lib/util/proteger.php"; $codigo = get_codigo(5); $senha = embaralhar($u->getSenha(), $codigo); $u->setCodigo($codigo); $u->setSenha($senha); $o = $u->persistir(); } } return $o; }