Welcome Guest, Not a member yet? Register   Sign In
Add new authentication variable in Community Auth
#1

Hi.

For application that I am developing, I want add a new authentication variable for it is available en views, controllers, etc.
Is very simple, I need have avatar's image of user that is logged in, to show it in the page, like his name or role.

I have created a new field in db table users, and when I have viewed Auth_Controller to modify it, in the property declarations, I haven't seen property $auth_email. It isn't necessary?

There are:
$auth_user_id
$auth_username
$auth_level
$auth_role

$auth_data
$acl
$protocol

But $auth_email isn't declared.
If I want add a new variable for use it before, I needn't declare it?

Thanks.
Reply
#2

This is the appropriate way to handle what you are attempting:

https://community-auth.com/blog-posts/in...r-profiles
Reply
#3

Ok, skunbad, thank you very much.

I had did:
- I added new field 'avatar' in users table.
- I added new property $avatar in Auth_Controller (public $avatar), and in the _set_user_variables() method, for controllers, views and config items.
- I added in get_auth_data() and check_login_status() methods, colum avatar and u.avatar to allow retrieve that avatar.
With that it works.

However, before I have read your blog post, I am going to modify to construct it according your recommendations.

Regards.
Reply
#4

Hi, skunbad.

I have had that you explain in the link that you posted about correct way to insert new information in profile data.
However, when I do the last step, autoload auth_model and my_auth_model in config/autoload.php, I get this error:
"Unable to locate the model you have specified: Auth_model".

Auth_model is in third_party/models, because in installation instructions about Community_Auth I don't see anything about move that file to application/models. If I don't autoload any file, all works fine. Is necessary autoload both files? Is necessary move Auth_model from third_party/models to application/models?

Thanks.
Reply
#5

(This post was last modified: 04-20-2017, 02:07 PM by skunkbad.)

(04-20-2017, 01:08 PM)annx10 Wrote: Hi, skunbad.

I have had that you explain in the link that you posted about correct way to insert new information in profile data.
However, when I do the last step, autoload auth_model and my_auth_model in config/autoload.php, I get this error:
"Unable to locate the model you have specified: Auth_model".

Auth_model is in third_party/models, because in installation instructions about Community_Auth I don't see anything about move that file to application/models. If I don't autoload any file, all works fine. Is necessary autoload both files? Is necessary move Auth_model from third_party/models to application/models?

Thanks.

You're right, Community Auth changed since the instructions were written. Autoloading is now handled in the _load_dependencies method inside Auth_Controller. So, no autoloading changes necessary. I updated the instructions. Thank you for letting me know.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB