You could run a simple check:
$error = trim($this->dx_auth->get_auth_error()); echo (strlen($error) > 0) ? "$error" : "";cheers,
naren
Worked great. Wonder why such function hasn’t a return code to check and returns directly the message
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
December 01, 2008 6:14am
Subscribe [160]#511 / Jul 30, 2009 6:14pm
You could run a simple check:
$error = trim($this->dx_auth->get_auth_error()); echo (strlen($error) > 0) ? "$error" : "";cheers,
naren
Worked great. Wonder why such function hasn’t a return code to check and returns directly the message
#512 / Jul 31, 2009 7:01pm
How can I ensure that the user is not logged in from another computer? I want to make sure that a given DX_user_id has only one record in the session table.
#513 / Aug 05, 2009 4:26am
There is one bug I found please make changes in the lib
We’ve one missing (=) in the function else there no advantage of using if statement.
There is only single = that means it will go everytime in function. If that is your purpose then remove if.
//corrected code by Yash
function _delete_autologin()
{
if ($auto == $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')))
{
// Load Cookie Helper
$this->ci->load->helper('cookie');
// Load Models
$this->ci->load->model('dx_auth/user_autologin', 'user_autologin');
// Extract data
$auto = unserialize($auto);
// Delete db entry
$this->ci->user_autologin->delete_key($auto['key_id'], $auto['user_id']);
// Make cookie expired
set_cookie($this->ci->config->item('DX_autologin_cookie_name'), '', -1);
}
}#514 / Aug 05, 2009 7:30am
There is one bug I found please make changes in the lib
We’ve one missing (=) in the function else there no advantage of using if statement.
There is only single = that means it will go everytime in function. If that is your purpose then remove if.//corrected code by Yash function _delete_autologin() { if ($auto == $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name'))) {
It looks like the same bug exists in the previous function as well.
//corrected code by North2Alaska
function autologin()
{
$result = FALSE;
if ($auto == $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')) AND ! $this->ci->session->userdata('DX_logged_in'))
{#515 / Aug 05, 2009 8:31am
Plz someone submit bug to author’s website
#516 / Aug 05, 2009 4:33pm
THIS IS NOT A BUG
please look at the statement carefully:
if ($auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')))Here the value of the cookie is being assigned to a variable called auto. If the cookie doesn’t exist, a false value is returned and gets assigned to the variable.
The if only checks to make sure that a cookie exists, and if it does then you enter the code in the if loop.
cheers.
naren
#517 / Aug 06, 2009 6:21pm
Hi guys, sorry foor being away for such a looooong time wirhout news.
Actually i’am suprised this thread still active, and feel bad at the same time because i just don’t show up.
so i say big thanks to all who has been contributing and donating (till now there is 2 ppl)
Well, here is the news about me
actually i’m pretty busy with my offline bussiness, i even barely coding now,
i don’t know if i can actively maintenance this lib anymore.
I’am happy if someone can maintenance this thread and update the code and upload it somewhere, maybe google code or etc.
I’ve also seen there is another library based on dx auth, maybe you should give it a shot.
Or maybe you can use acl library.
#518 / Aug 12, 2009 7:50am
Heyy there! I am using this library and need an answer to the following:
I want the user of my website to be able to register using their email id. i.e. I don’t want them to use the username field, email will be their username.
How do I achieve that, one way I thought was to pass email instead of username when calling register function in controller, but it will create redundancy, I want to completely remove the username field from the table.
#519 / Aug 12, 2009 11:58am
I’am happy if someone can maintenance this thread and update the code and upload it somewhere, maybe google code or etc.
I’ve also seen there is another library based on dx auth, maybe you should give it a shot.
Or maybe you can use acl library.
Could you make the whole script including the manual as a download. That would be very nice.
Thanks
#520 / Aug 13, 2009 5:19am
THIS IS NOT A BUG
please look at the statement carefully:
if ($auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')))Here the value of the cookie is being assigned to a variable called auto. If the cookie doesn’t exist, a false value is returned and gets assigned to the variable.
The if only checks to make sure that a cookie exists, and if it does then you enter the code in the if loop.
cheers.
naren
Not agreed what you’re saying or atleast this is not the process ...
It should be like this
some condition ? first : second
#521 / Aug 21, 2009 12:29am
Why would he need to use a ternary operator?
Here’s what you’re suggesting:
$auto = ($this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')) ? TRUE : FALSE;
if($auto)
...This is completely redundant because the ci->input->cookie returns a FALSE when it doesn’t exist. So here’s what’s really going on
$auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name');
if($auto)All the original author has done is combine those two lines into a single line. So again, this is not a bug.
Have you even read the code that follows: He can only run the query on the table and unset the cookie if the cookie exists and he extract values from it! What you’re suggesting will throw an error whenever someone tries to run it!
Naren
#522 / Aug 21, 2009 6:46am
ok may be this statement is true.
but we skip can $auto variable and use left statement then also it works. I mean why we assign it to some variable.
function return result can directly be used in if statement.
like
if($this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name'));Dude I’m arguing with you. I just want to improve my skills.
#523 / Aug 21, 2009 7:07am
@yash @narendranag is correct,
To elaborate @narendeanag’s point try running following code
<?php
if($auto = true) {
echo "Cookie Exist";
}
else echo "Cookie Don't Exist";U’ll notice that when a boolean true is passed, ‘Cookie Exist’ msg will be displayed and when false is passed other msg will appear.
also, every value grater that zero is considered true, so whenever a the following code is executed
if($auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name'));If statement will result a true if value greater that zero is returned to $auto, otherwise if the cookie doesn’t exist i.e.
$this->ci->config->item('DX_autologin_cookie_name')If above doesn’t exist then
$this->ci->input->cookie();will return zero and hence if will fail.
Hope this helps you!
#524 / Aug 21, 2009 7:46am
Yash,
Look at the function again,
..snip..
// Extract data
$auto = unserialize($auto);
// Delete db entry
$this->ci->user_autologin->delete_key($auto['key_id'], $auto['user_id']);
..snip..You need the cookie details—it’s own id and the user’s id. So instead of storing it in a variable later, the author stores it in a variable first.
cheers,
Naren
Naren
#525 / Aug 24, 2009 3:58am
Hi Folks,
I was wondering if anyone has added a ‘firstname’ and ‘lastname’ to the “users” table? If so, can you let me know what files I need to make changes to in order to utilize a person’s First name and Last name in the DX_Auth Library.
ADVthanksANCE.