Tank Auth v1.0 (CI authentication library) |
[eluser]theshiftexchange[/eluser]
Why does the Tank_Auth library force my user to be activated to use the 'forgot_password' option? The reason I ask is that you allow a user who is not activated to "send_again()" the activation email, or even select a new email for activation. Therefore, it is plausable that a user forgets their password when they are not activated; there is no harm in re-sending the email to the original email. The code from the tank_auth library is below: Code: function forgot_password($login) All you need to do is Code: if (!is_null($user = $this->ci->users->get_user_by_login($login, TRUE))) { Code: if (!is_null($user = $this->ci->users->get_user_by_login($login, $someconfigvalue))) { Cheers - and thanks again for all your hard work! edit: you will also need to use the same variable in the "reset_password" function - as it has activated hardcoded to TRUE aswell. I've 'hacked/modified' your library to hardcode both values to NULL, and it works perfectly for me as intended.
[eluser]theshiftexchange[/eluser]
one last idea/request: There should be a getUserEmail() function in the library. Because if you choose to NOT use a username, its because you are using the email as your login instead (which Tank Auth lets you decide in the config file). EDIT: Ok - I looked into this a bit more. You'll need to add the user email to the session, which is a good thing if people like myself are ONLY using emails - not usernames. on line 70 of tank_auth library: Code: $this->ci->session->set_userdata(array( just add Code: $this->ci->session->set_userdata(array( then add Code: function get_email()
[eluser]Benely[/eluser]
Hey, Love the system ![]() I want it so I can add an extra field on registration, I want it storing in the user_profile table, but where abouts is this done for the other fields in registration method? Thanks ![]()
[eluser]theshiftexchange[/eluser]
[quote author="Benely" date="1243018424"]Hey, Love the system ![]() I want it so I can add an extra field on registration, I want it storing in the user_profile table, but where abouts is this done for the other fields in registration method? Thanks ![]() In the auth.php file, go to the Register() function. You set the validation rules for all your fields, including the 'additional ones'. Then in the run() if statement, after the create_user function is called, you then add some lines to add the extra fields to your user_profile section.
[eluser]millo[/eluser]
Hey, Thought I would replace my redundant question with something useful. I have successfully installed Tank Auth on my Windows Xampp server and thought I would post a copy of my log here in case anyone comes up against the same problems that I encountered. Hope this is of help to somebody! :-) ... ### 30th May 2009 18:30 - Install Tank Auth Authentication ### Researched the available authentication packages available. Narrowed it down to about four (The Auth Library, DX Auth, Tank Auth (a reworked DX Auth?) and Redux). It got down to Redux and Tank Auth because they seemed to be more comprehensive with regards to it's features and they were both meant to be easy to install. Finally I decided on Tank Auth. I just seemed to like the responsiveness and enthusiasm of it's developer on the forums. http://ellislab.com/forums/viewthread/110993/ http://codeigniter.com/wiki/Tank_Auth/ http://konyukhov.com/soft/tank_auth/ Installing was easy enough. 1. Download the latest version of the library. 2. Unzip the package. 3. Copy the application folder content to your CI application folder. 4. Copy the captcha folder to your CI folder. Make sure this folder is writable by web server. 5. Install database schema into your MySQL database. 6. Open the application/config/config.php file in your CI installation and change $config['sess_use_database'] value to TRUE. To add to point 5. I also had to set the database settings in config/database.php. When I installed the Auth Library, the first thing I got was this error: --- Code: Object not found! I then thought that perhaps it had to do with the fact that I didn't have the .htaccess file in there so I got one out of an old project and put it in and it was fine. It talks about the .htaccess settings here: http://ellislab.com/codeigniter/user-gui.../urls.html Here is a copy of what I put in my .htaccess file. I used this setting when working on a previous project. It's used to remove the index.php from the url and also so that I can reference files that are in folders like '/css' and '/img' much more easily. I think I'd gotten most of the settings below from a forum but not sure which one as it was a while ago for another project. You might have to look for it if it's necessary. Code: <IfModule mod_rewrite.c> Some useful info on how to create overall file structure here: http://ellislab.com/forums/viewthread/57602/ After having installed the .htaccess file, the example forms provided by Tank Auth started rendering fine. However a few initial problems that I noted: 1. The font on the captcha image was too small. 2. When registering it tried to send off an email and running in XAMPP/Windows it seemed to be an issue. I solved both of them via this forum thread: http://ellislab.com/forums/viewthread/110993/ - Solving Problem 1: In system/application/config/tank_auth.php I made the following changes: Code: $config['captcha_fonts_path'] = 'captcha/fonts/3.ttf'; Code: $config['captcha_font_size'] = 18; - Solving Problem 2: In the thread mentioned above there is a link to the following page that solved problem number 2. http://i.justrealized.com/2008/05/02/how...-in-xampp/ These are what I changed the default settings in the following files: C:\xampp\sendmail\sendmail.ini: Code: smtp_server=mail.myserver.net C:\xampp\php\php.ini Code: SMTP = mail.myserver.net Remember! This is running off my laptop, Windows system so normally there is no mail server running, but this all seems to work now! Activation emails are being sent to me, even though gmail is classifying them as spam. I would imagine that's something that I can configure when it goes live. - Change to schema.sql file: I also modified the schema.sql file, it had the COLLATE settings as COLLATE utf8_bin and I changed them to COLLATE utf8_general_ci as that is what my general database collation is set at so that seems the appropriate thing to do. Hope that this is useful to somebody. Thanks Gromozeka! Nice Work! --- end
[eluser]millo[/eluser]
Hi Gromozeka I hope that you can help me. I've been trying to extend the code so that I can add more fields into the user_profile database. Here is what I've done: Added the extra fields into the database: Code: CREATE TABLE IF NOT EXISTS user_profiles ( Just tried experimenting first so thought I would try and get it to save just 'country' for first attempt. Added the necessary code into /views/auth/register_form.php and then also in the file /controllers/auth.php I added the necessary form validation code. That all ran fine up to there. I then modified the create_user function in libraries/Tank_auth.php: Code: /** and in models/tank_auth/users.php I modified the create_user() and create_profile(). I modified the information so that it goes into a data array and then extract it again when it's passed. Code: /** Code: /** Notice that in the create_user() function the variables echo correctly, yet when they're passed to the create_profile() function the user_id and country always return the values 1 and 1 respectively. The printf for the whole data array returns the correct value but only for the user_id. I don't really understand why the values aren't being passed correctly. Can you give me some guidance here?
[eluser]Gromozeka[/eluser]
[quote author="millo" date="1244122498"]Notice that in the create_user() function the variables echo correctly, yet when they're passed to the create_profile() function the user_id and country always return the values 1 and 1 respectively. The printf for the whole data array returns the correct value but only for the user_id. I don't really understand why the values aren't being passed correctly. Can you give me some guidance here?[/quote] Hi millo, I suppose that I know where's error in your code. Please notice if-condition in the 'create_user' metod of 'user' model: Code: if ($activated) $this->create_profile($user_profile_data); If you set 'email_activation' flag in config-file to TRUE, then $activated value in the code above will be FALSE, and 'create_profile' method won't be called here. It will be called later, on user activation by email. So if you want user profile to be created upon registration (not on activation) you have to get rid of this condition and comment 'create_profile' calling in 'activate_user' method of 'user' model: Code: function create_user($data, $activated = TRUE) Code: function activate_user($user_id, $new_email_key) Hope that it solves your problem :)
[eluser]millo[/eluser]
Thanks very much! Yes it does. I guess I'd need to add a new function for editing the user_profile now. What's the best practice with that? Do I put it in the /models/tank_auth/users.php file or in the libraries/tank_auth.php library file? I'm just uncertain because I've noticed that you have the same function names in both of these files, like delete_user() for example. Can you help me get a better understanding of why it's like this?
[eluser]Gromozeka[/eluser]
Hi millo, The library file is just an interface between controller and model. I consider the library structure as follows: - model -- simple getters and setters, to retrieve and save data - library -- process data from model or user (like validating user's password) - controller -- control behaviour of the end-user interface So if you just want to get data from user_profile table and show them to user, or save user input to database, there's no needs in extra-layer between model and controller. Just add another model file, put all required methods in it an call them directly from controller.
[eluser]Zewt[/eluser]
Have a small question. I have been testing out Tank Auth and am running into this db error. Quote:A Database Error Occurred The Code: user_data Code: `user_data` text COLLATE utf8_bin NOT NULL, Any ideas why I seem to be the only one having a problem with this? |
Welcome Guest, Not a member yet? Register Sign In |