Codeigniter integrated TankAuth permission class library-PHP Tutorial

Source: Internet
Author: User
Tags codeigniter
Codeigniter integrates the TankAuth permission class library. Interconnect other CodeIgniter class libraries, tank_auth, simple configuration, easy to use, and the author has been updating, now 1.0.9. 1.0.8 already supports CI2.0. Currently, the common project that communicates with other CodeIgniter class libraries, tank_auth, is easy to configure and use, and the author has been updating it. now it is 1.0.9. 1.0.8 already supports CI2.0, so I recommend it to you for general projects.

Install Tankauth

Download the latest class library (: http://www.konyukhov.com/soft/tank_auth/tank_auth.zip)

Decompress the file
Copy the corresponding files under the application to your CIapplication folder.
Copy the captcha folder to your CI folder (the project directory, the same as the application directory) and make sure that the directory is writable under the web server.
Install the database (schema. SQL file) structure in your MySQL database.
Open the application/config. php file in your CI project, and change the value of $ config ['sess _ use_database '] to TRUE.
Installation complete!

If the following error occurs during access:

AnErrorWasEncountered
InordertousetheSessionclassyouarerequiredtosetanencryptionkeyinyourconfigfile.

This error indicates that a key is required. Open config. php and add a key after $ config ['encryption _ key.

TankAuth official website address:Http://www.konyukhov.com/soft/tank_auth/

If an error occurs, do not forget to check the configuration file (tank_auth.php and email. php). after the installation is complete, the class library should work perfectly. but it is best to modify the library according to your server conditions and your needs.

Tip: by default, the class library generates a powerful system-specific password and the HSR value cannot be transplanted. This means that once created, the user database cannot be exported and imported to other databases, this feature can also be modified through the configuration file.

Brief description of Tankauth class library

The class library uses the MVC model, which means that all database-related methods are encapsulated in the model file, and the class library itself serves as an interface for these methods. Request from the controller (auth), call the method in the class library, and render the view (displayed in the browser or sent by email ). The controller includes the following methods:

Login: log on to the website. If the logon succeeds and the user account is activated, the user will be redirected to the home page. If it is not activated, send_again will be called (see below ). If logon fails, the user will remain on the same page (logon page );
Logout: log out of the user.
Register: register a user to the website. If the account is successfully registered, a user account is created. If the value of the email_activation item in the configuration file is set to TRUE, you need to click a special connection sent to the email to activate the account; otherwise, the account is activated by default. Note: After registration, the user does not pass the logon verification and still needs to log on.
Send_again: send an activation email to the same or new email address. This method is called every time you log on to activate a user. This function is useful when a user does not receive a letter due to a mailbox problem or incorrect emial address. Users can change their email or remain unchanged.
Activate: activate the user account. This method is usually activated by clicking the link in the email. You can click "forgotpassword" and enter email to activate the account. Users are authenticated by the user Id and verification code in the URL.
Forgot_password: generate a special reset code (to change the password) and send it to the user. Obviously, this method is used only when the user forgets the password.
Reset_password: replace the old (forgot) password with a new (user-set) password. This method can be called by clicking the connection in the email. Users are authenticated by the user Id and verification code in the URL.
Change_password: "normal" password change (compared to Password reset ). Users can only be called upon logon and activation. To ensure security, you still need to verify the user's secret.
Change_email: modify the user's email. Users can only be called upon logon and activation. To ensure security, you still need to verify the user's secret. This new email can be activated only by clicking the link sent to this email.
Reset_email: activate the new email address and replace it with a new email address. You can call this method by clicking the link in the email. Users are authenticated by the user Id and verification code in the URL.
Unregister: deletes a user account. Users can only be called upon logon and activation. To ensure security, you still need to verify the user's secret.

Since the auth controller manages the user's methods (including logon and logout), you may not have to directly call the methods in the class library. However, the following must be called:

Is_logged_in: checks whether users log on to the website.
Get_user_id: if the user logs on, the user ID is obtained; otherwise, FALSE is returned.
Get_username: obtain the user name of the authenticated user; otherwise, FALSE is returned. If the user name is not registered, calling this method is meaningless (at this time, any user will return an empty string ).

Bytes. 1.0.8 already supports CI2.0. my current general projects...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.