public static function Authenticate($email, $password, $level_required) { $perfil = Perfil::with('user')->where('email', '=', $email)->get(); if (count($perfil) == 0) { return false; } else { $salt = $perfil[0]->user->salt; $hash = hash('sha256', $password . $salt); if ($hash == $perfil[0]->user->passwd) { self::loadProfil($perfil[0]->user); if (self::checkAccessRights($level_required)) { return true; } else { return false; } } else { return false; } } }
public function cursosView($username) { $username = strip_tags(htmlspecialchars($username)); $username = filter_var($username, FILTER_SANITIZE_STRING); $perfil = Perfil::with('user', 'cursos')->where('username', '=', $username)->get(); $perfil = $perfil[0]; $session = Utilities::getSession(); $links = Utilities::getMenu($session); $logged = null; foreach ($perfil->cursos as $key => $value) { $value->action = '/curso/' . $value->nombre; } if (is_null($session)) { $logged = false; } else { $logged = true; } $this->view = new MisCursos($perfil, $logged, $links); $this->view->display(); }