agora tenho outra dúvida sobre o Auth, quando utilizo o codigo:
function __construct(){
parent::__construct();
$this->session= Session::instance();
$authentic=new Auth;
if (!$authentic->logged_in('admin')){
$this->session->set("requested_url","/".url::current
<http://www.php.net/current>()); // this will redirect from the login
page back to this page/
url::redirect('/user/login');
}else{
$this->user = $authentic->get_user(); //now you have access to
user information stored in the database
}
}
justamente para nesse controller so poder entrar user logado como
admin. pq ele sempre
entra no else, mesmo o user tendo role 'admin'?
Obg Atencipadamente...
Em 23 de julho de 2010 10:45, Fernando Lopes
<[email protected]>escreveu:
> RESOLVIDO!
>
> Em 22 de julho de 2010 21:50,
> <[email protected]<kohana-php%[email protected]>
> > escreveu:
>
> Resumo do tópico de hoje
>>
>> Grupo: http://groups.google.com/group/kohana-php/topics
>>
>> - Não consigo logar no module
>> auth<#129ff8d748443e87_129fcc75034d18bd_group_thread_0>[1 atualização]
>>
>> Tópico: Não consigo logar no module
>> auth<http://groups.google.com/group/kohana-php/t/ddf0710928f25c7c>
>>
>> Fernando Lopes <[email protected]> Jul 22 12:03PM -0300
>> ^<#129ff8d748443e87_129fcc75034d18bd_digest_top>
>>
>> bom dia a todos, fiz uma aplicação e estou tentando usar o module auth
>> do
>> kohana, consigo criar o usuario com os exemplos usados na documentação
>> http://docs.kohanaphp.com/addons/auth#logout , mas utilizando a mesma
>> para
>> fazer o login sempre da erro, vou postar o controller e as views
>> estou usando o module auth e não fiz nenhuma alteração nos arquivos da
>> pasta
>> modules/auth.
>> apenas copiei o modules/auth/config/auth.php para application/config.
>> e
>> mudei algumas coisas como tinha no exemplo.
>> por favor alguem poderia me ajudar?
>>
>> ========Controller============
>> public function index(){
>>
>> $this->form = array
>> (
>> 'username' => '',
>> 'password' => '',
>> );
>> $this->errors = $this->form;
>> if (Auth::instance()->logged_in('login')) {
>> url::redirect('admin/index');
>> } else if (Auth::instance()->logged_in()) {
>> url::redirect('accessdenied'); //User hasn't confirmed account yet
>> }
>>
>> //Initialize template and form fields
>> $this->template_html->title = 'Login';
>> $this->template_site->corpo = new View('login/index');
>>
>> //Attempt login if form was submitted
>>
>> if ($post = $this->input->post()) {
>> if (ORM::factory('user')->login($post)) {
>> url::redirect('admin/index');
>> } else {
>> $this->form['username'] = $post['username']; //Redisplay
>> username (but not password) when form is redisplayed.
>> $this->template_site->corpo->message = in_array('required',
>> $post->errors()) ? 'Usuário e senha são requeridos.' : 'Usuário e/ou
>> Senha
>> Inválidos.';
>> }
>> }
>> $this->template_site->corpo->form = $this->form;
>> $this->template_site->corpo->errors = $this->errors;
>> }
>>
>> ===============end controller ================
>>
>> ==========View====================
>> <div style="width:300px;height:200px;">
>>
>> <?php if (isset($message)): ?>
>> <div class="error" style="color: red;">
>> <?=$message?>
>> </div>
>> <?php endif; ?>
>>
>> <div id="tela">
>> <?php
>> echo form::open(null);
>>
>> echo form::label('username','login: ');
>> echo form::input('username',$form['username']);
>> echo (isset($errors['username'])) ? $errors['username'] : '';
>> ?>
>>
>> <br /><br />
>> <?php
>> echo form::label('password','senha:');
>> echo form::password('password');
>> echo (isset($errors['password'])) ? $errors['password'] : '';
>> ?>
>> <br />
>> <?php echo form_Core::checkbox('remember', 'true') ?>
>> <?php echo form::label('remember','Salvar as minhas informações
>> neste computador.') ?>
>> <br />
>> <?php echo form::submit('entrar','entrar'); ?>
>>
>> <?php echo form::close(); ?>
>> </div>
>>
>> </div>
>> ==============end View=============================
>>
>> ==============application/config/auth.php================
>> <?php defined('SYSPATH') OR die('No direct access allowed.');
>> /**
>> * Auth library configuration. By default, Auth will use the controller
>> * database connection. If Database is not loaded, it will use use the
>> default
>> * database group.
>> *
>> * In order to log a user in, a user must have the `login` role. You
>> may
>> create
>> * and assign any other role to your users.
>> */
>>
>> /**
>> * Driver to use for authentication. By default, LDAP and ORM are
>> available.
>> */
>> $config['driver'] = 'ORM';
>>
>> /**
>> * Type of hash to use for passwords. Any algorithm supported by the
>> hash
>> function
>> * can be used here. Note that the length of your password is
>> determined by
>> the
>> * hash type + the number of salt characters.
>> * @see http://php.net/hash
>> * @see http://php.net/hash_algos
>> */
>> $config['hash_method'] = 'sha1';
>>
>> /**
>> * Defines the hash offsets to insert the salt at. The password hash
>> length
>> * will be increased by the total number of offsets.
>> */
>> //$config['salt_pattern'] = '1, 3, 5, 9, 14, 15, 20, 21, 28, 30';
>> $config['salt_pattern'] = '1, 5, 6, 15, 17, 18, 19, 22, 24, 39';
>>
>> /**
>> * Set the auto-login (remember me) cookie lifetime, in seconds. The
>> default
>> * lifetime is two weeks.
>> */
>> $config['lifetime'] = 1209600;
>>
>> /**
>> * Set the session key that will be used to store the current user.
>> */
>> $config['session_key'] = 'auth_user';
>>
>> /**
>> * Usernames (keys) and hashed passwords (values) used by the File
>> driver.
>> * Default admin password is "admin". You are encouraged to change
>> this.
>> */
>> $config['users'] = array
>> (
>> // 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
>> );
>> =============end auth.php================================
>>
>>
>>
>> --
>> Você está recebendo esta mensagem porque se inscreveu no grupo "Kohana
>> Php" dos Grupos do Google.
>> Para postar neste grupo, envie um e-mail para [email protected]
>> .
>> Para cancelar a inscrição nesse grupo, envie um e-mail para
>> [email protected]<kohana-php%[email protected]>
>> .
>> Para obter mais opções, visite esse grupo em
>> http://groups.google.com/group/kohana-php?hl=pt-BR.
>>
>
>
--
Você está recebendo esta mensagem porque se inscreveu no grupo "Kohana Php" dos
Grupos do Google.
Para postar neste grupo, envie um e-mail para [email protected].
Para cancelar a inscrição nesse grupo, envie um e-mail para
[email protected].
Para obter mais opções, visite esse grupo em
http://groups.google.com/group/kohana-php?hl=pt-BR.