Welcome Guest, Not a member yet? Register   Sign In
MeNeedz Auth
#51

[eluser]charlie spider[/eluser]
yup figured that one out, got the form up, typed in some gibberish and get this:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$db

Filename: libraries/Auth.php

Line Number: 176

Fatal error: Call to a member function escape() on a non-object in C:\xampp\htdocs\tofino\application\libraries\Auth.php on line 176


is this only because i'm testing this with empty tables and no form validation, or because i haven't initialized the config ?
#52

[eluser]davidbehler[/eluser]
Do you have the db library loaded?
If you the variable "use_database" is set to TRUE then you have to load the database library in order to use the auth library. Just add 'database' to $autoload['libraries'] in your autoload.php and don't forget to edit the database.php in your config folder.
#53

[eluser]ray73864[/eluser]
[quote author="louis w" date="1227144681"]Looks promising. But i would not want to place an if($this->auth->has_access('user') inside each one of my methods. You should try to move something like this into the constructor so it can be global to the controller.[/quote]

having it as a global in the controller may not always be good, you might want to lock a function to a specific group.


oh, i have a project lined up for this auth library, i just need motivation to scrap my existing one (a pretty crappy and basic authentication) and stick this one in, motivation is hard to find, but since i am redoing my cms (now that i know how to use models and all), i shall be sticking this in.
#54

[eluser]pembelajar[/eluser]
[quote author="charlie spider" date="1227154411"]A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$session

Filename: libraries/Auth.php

Line Number: 301[/quote]

I put
Code:
$this->CI->load->library('session');
at line 92, to handle this error, or maybe you can put them on your controller.
#55

[eluser]charlie spider[/eluser]
ya you don't need to add it to the auth library itself

just add
Code:
$this->load->library('session');
to your controller

that was the easy problem. i only posted to let him know to update his instructions. the problem i had that threw me was when i forgot to load the freakin database! it's the only thing i usually have autoloaded and therefore never add it to a controller. but now i'm working with a fresh copy of CI 1.7 instead of a copy, and so BAM no database, and i was like "HEH????"
completely dumbfounded. forgot all about loading the database. he he he

most of the time i'm pretty smart, but i make up for it by having moments of absolutely brilliant idiocy.
#56

[eluser]pembelajar[/eluser]
@charlie spider
Ok, teacher ;-)
#57

[eluser]JimmyPHP[/eluser]
Thanks, good, simple auth library. In the example code on user guide, a small typo:

Code:
...
    function access_test()
    {
        if($this->auth->has_access('user')
...

fixed with

Code:
...
    function access_test()
    {
        if($this->auth->has_access('user'))
...
#58

[eluser]SaSHka[/eluser]
Greetings, I can not understand with METHOD Login ().
To be registered it has turned out, and here to come on site is impossible
There are problems with $password_hash in inquiry to a database is written
SELECT *
FROM (` user `)
WHERE ` user_name ` = ' sashka '
AND user_password =md5 (concat (user_salt, ' 123123 '))
LIMIT 1

I Am sorry for my bad English :cheese:
#59

[eluser]davidbehler[/eluser]
What kind of problem are you talking about?

Is there an error message you can show?

@JimmyPHP: Thanks! Fixed
#60

[eluser]SaSHka[/eluser]
Error messages are not shown!
I in the controller have included
$this-> output-> enable_profiler (TRUE);

Code:
function Welcome()
    {
        parent::Controller();
        
        $this->output->enable_profiler(TRUE);
    }

My controller
Code:
function login()
    {
        if($this->auth->is_logged_in())
        {
            echo "logged in";
        }
        else
        {
            $login = $this->auth->login();
            if($login)
            {
                redirect('welcome/login');
            }
            else
            {
                $this->load->view('login');
            }
        }
    }

My view
Code:
<html>
<head>
<title>Welcome to CodeIgniter</title>

<body>
<?
    echo form_open('welcome/login');
    $data = array(
                  'name'        => 'user_name',
                  'id'          => 'user_name',
                  'maxlength'   => '50',
                  'size'        => '50'
                );
    echo form_input($data);
?>
<br/>
&lt;?
    $data = array(
                  'name'        => 'user_password',
                  'id'          => 'user_password',
                  'maxlength'   => '50',
                  'size'        => '50'
                );
    echo form_password($data);
?&gt;
<br/>
&lt;?
    echo form_submit('mysubmit', 'Submit Post!');
    echo form_close();
?&gt;
&lt;/body&gt;
&lt;/html&gt;

And so not login and errors does not show!




Theme © iAndrew 2016 - Forum software by © MyBB