本文整理汇总了PHP中Auth::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::get方法的具体用法?PHP Auth::get怎么用?PHP Auth::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_profile
public function action_profile()
{
$data = null;
$data['user'] = Model_User::query()->related('user_providers')->where('id', static::$user_id)->get_one();
$data['api_key'] = Auth::get('api_key');
if (Input::Method() == 'POST') {
$new_password = Input::Post('new_password');
$current_password = Input::Post('current_password');
if (empty($new_password) === false) {
if (empty($current_password) === true) {
Session::set('error', 'You must enter your old password in first!');
$this->template->content = View::Forge('settings/profile', $data);
return;
} else {
if (Auth::change_password($current_password, $new_password) === false) {
Session::set('error', 'Wrong Password');
$this->template->content = View::Forge('settings/profile', $data);
return;
} else {
Session::delete('current_password');
}
}
}
// update the data for the current user
try {
Auth::update_user(array('email' => Input::Post('email'), 'fullname' => Input::Post('full_name')));
} catch (Exception $e) {
Session::set('error', $e->getMessage());
$this->template->content = View::Forge('settings/profile', $data);
return;
}
Session::set('success', 'Your profile has been updated');
}
$this->template->content = View::Forge('settings/profile', $data);
}
示例2: nueva_carpeta
public function nueva_carpeta($nombre_carpeta)
{
$carpeta_nueva = new Carpeta();
$carpeta_nueva->nombre = $nombre_carpeta;
$carpeta_nueva->usuario_id = Auth::get("id");
return $carpeta_nueva->save();
}
示例3: initialize
protected final function initialize()
{
$controller = Router::get("controller");
$action = Router::get("action");
$ruta = $controller . "/" . $action;
$tipousuario = Auth::get("tipousuario");
if (Auth::is_valid()) {
if ($tipousuario == "alumno") {
if ($ruta != "perfil/index" and $ruta != "perfil/logout" and $ruta != "asistencia/alumno") {
Flash::warning("Acceso Denegado");
Router::redirect("perfil/");
}
}
if ($tipousuario == "docente") {
$permisos = array("perfil/actualizar", "perfil/cambiarpass", "perfil/index", "perfil/programarevaluaciones", "calificar/grupo", "perfil/logout", "asistencia/index", "asistencia/agregar_asistencia");
if (!in_array($ruta, $permisos)) {
Flash::warning("Acceso Denegado");
Router::redirect("perfil/");
}
}
} else {
if ($ruta != 'index/index' and $ruta != 'perfil/logout') {
Flash::warning("Acceso Denegado");
Router::redirect("index/index");
}
}
}
示例4: initialize
protected final function initialize()
{
$recurso = '';
if ($this->module_name == 'admin') {
View::template('admin');
if ($this->module_name) {
$recurso = "{$this->module_name}/{$this->controller_name}/{$this->action_name}/";
} else {
$recurso = "{$this->controller_name}/{$this->action_name}/";
}
if (Auth::get('rol_id') == 5) {
Flash::warning("No tienes permiso para acceder.");
View::select(null, '401');
return FALSE;
}
Load::lib('SdAuth');
if (!SdAuth::isLogged()) {
$this->error_msj = SdAuth::getError();
View::template('login');
return FALSE;
}
$ku_acl = new KuAcl();
$ku_acl->cargarPermisos(Auth::get('id'));
if (!$ku_acl->check($recurso, Auth::get('id'))) {
Flash::warning("No tienes permiso para acceder al siguiente recurso: <b>{$recurso}</b>");
View::select(null, '401');
return FALSE;
}
}
}
示例5: initialize
protected final function initialize()
{
View::template('sbadmin');
/// para el template, todos los controladores que invoquen el appcontroller se va a invocar la plantilla
//esto evita que en cada controlador se haga llamado de la plantilla
//Si en otro controlador hago llamado a otra plantilla, se sobreescribira esta linea
if (Auth::is_valid()) {
$this->userRol = Auth::get("rol");
}
$this->acl = new Acl();
//Se agregan los roles
$this->acl->add_role(new AclRole('lector'));
// Visitantes
$this->acl->add_role(new AclRole('editor'));
// Administradores
$this->acl->add_role(new AclRole('administrador'));
// Usuarios
$this->acl->add_role(new AclRole(''));
//Se agregan los recursos osea todos los controladores con sus funciones
$this->acl->add_resource(new AclResource('usuario'), 'ingresar');
$this->acl->add_resource(new AclResource('usuariocrud'), 'index', 'edit');
$this->acl->add_resource(new AclResource('registro'), 'index', 'crear');
//Se crean los permisos osea va 'tipoUsuario o rol','nombre_controlador' array('funcion1','funcion2','y las que quieran')
// Inicio
$this->acl->allow('administrador', 'usuariocrud', array('index', 'edit'));
$this->acl->allow('administrador', 'registro', array('index', 'crear'));
$this->acl->allow('editor', 'usuariocrud', array('edit'));
$this->acl->allow("lector", 'usuariocrud', array('index'));
$this->acl->allow('', 'usuario', array('ingresar'));
}
示例6: edit
public function edit($id)
{
$usuario = new Usuario();
$this->titulo = "Editar Usuario";
$this->titulo2 = "";
$this->usuaior = Auth::get('nombre');
//se verifica si se ha enviado el formulario (submit)
if (Input::hasPost('Usuario')) {
if ($_POST['Usuario']['rol'] == 'administrador' or $_POST['Usuario']['rol'] == 'editor') {
//Al directorio public hay que darle premisos 777
$carpeta = new Carpeta();
$nombrecarpe = $_POST['Usuario']['nombreusuario'];
// crea una careta en default puplic
$carpetaid_contenedor = NULL;
$carpeta->insertar_carpeta_editar($carpetaid_contenedor, $nombrecarpe);
if (!file_exists($nombrecarpe)) {
if (!mkdir($nombrecarpe, 0777, true)) {
die('Fallo al crear las carpetas...');
}
}
}
if (!$usuario->update(Input::post('Usuario'))) {
Flash::error('Falló Operación');
} else {
Flash::valid('Operación exitosa');
//enrutando por defecto al index del controller
return Router::redirect();
}
} else {
//Aplicando la autocarga de objeto, para comenzar la edición
$this->Usuario = $usuario->find((int) $id);
}
}
示例7: makeUserInfo
function makeUserInfo()
{
$userInfo = '';
if (Auth::check()) {
$userInfo .= ' UserName:' . Auth::get('username') . '(' . Auth::get('id') . ')';
}
return $userInfo;
}
示例8: getSubjectOptions
/**
* Gets all subjects as options used for forms
*
* @return array the subjects as assoc array ['id' => 'value']
*/
public static function getSubjectOptions()
{
$where = [];
if (!Model_User::is_current_user('admin')) {
$where = ['user_id' => Auth::get('id')];
}
$subjects = static::find('all', ['where' => $where]);
return Arr::assoc_to_keyval($subjects, 'id', 'subject_code');
}
示例9: before
public function before()
{
parent::before();
if (!Auth::check()) {
Response::redirect('index');
}
if (Auth::get('group_id') == 6) {
return Response::forge('index');
}
}
示例10: Action_Index
public function Action_Index()
{
if (!Auth::check()) {
return Response::redirect('auth/login?url=' . Input::uri());
}
$data["auth_username"] = Auth::get('username', 'Unnamed');
$this->template->title = "Fuck you!";
$this->template->auth_username = $data["auth_username"];
$this->template->content = View::Forge('dashboard/index', $data);
}
示例11: before
public function before()
{
// Lets render the template
parent::before();
// Check to see if the config exsists
if (file_exists(APPPATH . 'config/production/db.php') === false) {
Response::Redirect('install');
}
if (DBUtil::field_exists('urls', array('cached_preview')) === false && file_exists(APPPATH . 'classes/controller/upgrade.php')) {
Response::Redirect(Uri::Create('upgrade'));
}
$real_base_url = Config::get('base_url');
Config::set('base_url', str_replace('public/', '', $real_base_url));
$base_url = Settings::get('different_short_url');
if (empty($base_url) === false) {
View::set_global(array('base_url' => $base_url), false, false);
}
if (trim(Uri::Base(), '/') == Settings::get('different_short_url')) {
if (count(Uri::Segments()) == 2) {
$route = Uri::to_assoc();
if (isset($route) === true && $route['core'] == '404') {
// We are good!
} else {
Response::Redirect(Settings::Get('base_url'));
}
} else {
Response::Redirect(Settings::Get('base_url'));
}
}
$data = null;
if (Auth::Check()) {
$user_id = Auth::get_user_id();
static::$user_id = $user_id[1];
$data['api_key'] = Auth::get('api_key');
if (empty($data['api_key']) === true) {
if (empty($data['api_key']) === true) {
$data['api_key'] = preg_replace('/\\+|\\/|\\=|\\?/', '', \Auth::instance()->hash_password(\Str::random()) . static::$user_id);
// invalidate the hash
\Auth::update_user(array('api_key' => $data['api_key']), Auth::get('username'));
}
}
}
// Lets set the default title , you can change it when calling the view
$this->template->title = ucwords(str_replace('controller_', '', strtolower($this->request->route->controller)));
try {
Module::load('image');
$this->template->image_js = true;
} catch (Exception $e) {
}
// Lets get the header and footer and set a variable to use within the template
$this->template->footer = View::forge('core/footer', $data);
$this->template->header = View::forge('core/header');
}
示例12: create
/**
* Crea un nuevo articulo
*
*/
public function create()
{
if (Input::hasPost('articulo')) {
if ($articulo = Articulo::input('create', Input::post('articulo'))) {
$articulo_etiqueta = new ArticuloEtiqueta();
$articulo_etiqueta->addTagsPost(Input::post('tags'), $articulo->id);
return Router::redirect('admin/articulo/');
}
}
$this->usuario_id = Auth::get('id');
//$this->autor = Auth::get('nombre');
}
示例13: miscontactos
public function miscontactos()
{
if (Auth::is_valid()) {
# code...
$id = Auth::get("id");
$this->usuario = Load::model("usuarios")->find($id);
$this->contactos = Load::model("usuarios_contactos")->find("join: inner join usuarios on usuarios.id = usuarios_contactos.usuarios_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t inner join contactos on contactos.id = usuarios_contactos.contactos_id", "columns: contactos.nombre, contactos.descripcion, contactos.email, contactos.created, contactos.id", "conditions: usuarios_id = '{$id}'");
} else {
Flash::warning("Usuario no autenticado");
Router::redirect("index/login");
}
}
示例14: build
public static function build($class_name)
{
$class_name = str_replace(['/', '.'], '\\', $class_name);
$class_name = preg_replace_callback('/(\\\\.)/', function ($matches) {
return strtoupper($matches[1]);
}, $class_name);
$class_name = ucfirst($class_name);
if (strcasecmp($class_name, 'task\\list') === 0) {
$class_name = 'Task_List';
}
$class_name = '\\' . __NAMESPACE__ . '\\' . $class_name;
return forward_static_call_array([$class_name, 'getInstance'], Auth::get());
}
示例15: action_update
public function action_update($username = 'k000c0000')
{
//バリデーション定義
$val = Validation::forge();
//ニックネームは必須で、最大文字数は50文字以内
$val->add('name', '「ニックネーム」')->add_rule('required')->add_rule('max_length', 50);
//メールアドレスは必須で、入力内容がメールの形式に沿っているか
$val->add('email', '「メールアドレス」')->add_rule('required')->add_rule('valid_email');
$class = Auth::get('classID');
//ログイン中の学生のレコードを取得する
$user = Model_Users::find($username);
//各カラムに更新情報を格納する
$user->fullname = Input::post('name');
$user->email = Input::post('email');
//アップロードファイルがバリデーション通りなら投稿内容保存
if (Upload::is_valid()) {
//設定を元に保存をする
Upload::save();
foreach (Upload::get_files() as $file) {
$user->icon = $file['saved_as'];
}
}
if ($val->run()) {
$user->save();
//更新後のレコードを取得する
$this->data['users'] = Model_Users::query()->where('username', '=', $username)->get();
$this->data['classname'] = Model_Class::query()->where('classID', '=', $class)->get();
$this->action_categorise();
//ビューオブジェクトの作成
$view = View::forge('changeregistration/ChangeRegistration', $this->data);
//ビューのmessage変数に更新成功時のメッセージを定義
$this->message = '登録内容を変更しました。';
//ビューに渡す変数をセットメソッドで定義する
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
} else {
//現在のレコードを取得する
$this->data['users'] = Model_Users::query()->where('username', '=', $username)->get();
$this->data['classname'] = Model_Class::query()->where('classID', '=', $class)->get();
$this->action_categorise();
//バリデーションからエラーメッセージを取得する
$this->error = $val->error();
//ビューオブジェクト生成
$view = View::forge('changeregistration/ChangeRegistration', $this->data);
//ビューに渡す変数をセットメソッドで定義する
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
}
//ビューを返す
return $view;
}