CodeIgniter Integration Tank AUTH Permission class Library detailed _php example

Source: Internet
Author: User
Tags auth codeigniter

Intersect other CodeIgniter class libraries, Tank_auth, configuration is simple, use is simple, and the author has been updated, is now 1.0.9. 1.0.8 has supported the CI2.0, I now general projects are used it, so recommended to everyone.

Steps to install Tankauth

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

Extract Files
Copy the appropriate files under Application to your Ciapplication folder.
Copy the Captcha folder to your CI folder (the project directory, and application the same 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/config.php file under your CI project and change the value of $config[' Sess_use_database ' to true.
Installation Complete!

If the access has the following error:

Anerrorwasencountered
Inordertousethesessionclassyouarerequiredtosetanencryptionkeyinyourconfigfile.

This error prompt requires a key. Then open config.php, after $config[' Encryption_key '], just add a key.

Tankauth official website address:http://www.konyukhov.com/soft/tank_auth/

If there are errors, do not forget to look at the configuration files (tank_auth.php and email.php), after the installation of the class library should be able to work perfectly, but according to your server conditions and your needs, it is best to selectively modify.

Tip: By default, class libraries produce powerful system-specific passwords the value of the HA is not portable, which means that once created, the user database cannot be exported and imported into another database, and this feature can also be modified by a configuration file.

A simple description of the Tankauth class library

The class library employs an MVC model, which means that all database-related methods are encapsulated in the model file, and the class library itself is the interface for these methods. Controller (auth) and calls methods in the class library to render the corresponding view (displayed in the browser or sent by email). The controller includes the following methods:

Login: The user logs on to the site. If the login is successful and the user account is active, the user will be redirected to the home page. If it is not activated, Send_again will be invoked (see below). If the login fails, the user will remain on the same page (login page);
Logout: Log off the user.
Register: Registers the user to the website. If the registration is successful, a user account is created. If the value of the Email_activation item in the configuration file is set to True, the user needs to activate the account by clicking on the special connection sent to the email, otherwise activated by default. Please note: After registering, the user is not authenticated by login and still needs to log in.
Send_again: Send the activation email again to the same or new email address. When logging in for the active user is, this method is invoked each time. This function is useful when a user does not receive a letter due to a problem with the mailbox or the wrong emial address. Users can change their email or stay the same.
Activate: Activate user account. Usually this method is activated by clicking on the link call in email. You can activate your account by clicking "Forgotpassword" and entering email. The user is authenticated by the ID and authentication code of the user in the URL.
Forgot_password: Generates a special reset code (to modify the password) and sends it to the user. It is obvious that users will use this method when they forget their passwords.
Reset_password: Replaces the old (forgotten) password with a new (user-set) password. This method can be invoked by clicking on the connection in the message. The user is authenticated by the ID and authentication code of the user in the URL.
Change_password: "Normal" password modification (compared to resetting the password). Can only be invoked when a user logs on and is activated. To ensure security, you still need to authenticate user secrets.
Change_email: Modify the user's email. Can only be invoked when a user logs on and is activated. To ensure security, you still need to authenticate user secrets. This new email can only be activated by clicking on the link sent to the email.
Reset_email: Activate the new email address and replace it with a new email address. You can call the method by clicking on the link in the message. The user is authenticated by the ID and authentication code of the user in the URL.
Unregister: Delete user account. Can only be invoked when a user logs on and is activated. To ensure security, you still need to authenticate user secrets.

Since the Auth controller manages the user's methods (including logon and logoff), you may not necessarily want to call the methods in the class library directly. But here are some things to call:

Is_logged_in: Detects whether a user is logged on to a Web site.
GET_USER_ID: If the user logs in, gets the user ID, otherwise returns false.
Get_username: Gets the user name of the authenticating user, otherwise returns false. Calling this method is meaningless if the user name is not registered (at which point any user will return an empty string).

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.