Add new authentication variable in Community Auth - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7) +--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13) +--- Thread: Add new authentication variable in Community Auth (/showthread.php?tid=67835) |
Add new authentication variable in Community Auth - annx10 - 04-16-2017 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. RE: Add new authentication variable in Community Auth - skunkbad - 04-16-2017 This is the appropriate way to handle what you are attempting: https://community-auth.com/blog-posts/intro-to-user-profiles RE: Add new authentication variable in Community Auth - annx10 - 04-17-2017 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. RE: Add new authentication variable in Community Auth - annx10 - 04-20-2017 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. RE: Add new authentication variable in Community Auth - skunkbad - 04-20-2017 (04-20-2017, 01:08 PM)annx10 Wrote: Hi, skunbad. 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. |