Giter Site home page Giter Site logo

cith's Introduction

CITH

A Simple and complete authentication library for Codeigniter.

Installation:

First you will need to add a copy of cith.php in the app/libraries . After that we should add the configuration variables in app/config/config.php .

// - Auth Security
$config['Cith_cryptCost'] = '12';
$config['Cith_loginPage'] = '/login';

// - Auth Database
$config['Cith_table'] = 'accounts'; // Accounts table name.
$config['Cith_loginIndex'] = 'email'; // Username or Email column name.
$config['Cith_passIndex'] = 'password'; // Password column name.

Now you can load the library in a controller, with: (we recommend load it in the constructor)

 $this->load->library('cith');

How to use:
  • Creating a new account:

In the array you can put how many items do you want, all will be written in the database, but remember, you need to put the configured login and password indexes.

$this->cith->register([
      'email' => '[email protected]', // required item
      'password' => 'admin', // required item
      'nickname' => 'Super Admin' // optional item
], false) // if you want a session to be created after the registration, set true.
  • Logging in a account:

This function can return invalid-login, invalid-password or authenticated.

this->cith->login('[email protected]', 'admin');
  • Logging out a account:

If you call without any parameter this function will redirect to login page.

this->cith->logout('/exit-page');
  • Retrieving account data.

This will return a object with all account data, you can set the boolean to true if you want a uncached data, this will request a updated data from database.

this->cith->account(false);
  • Defining a restricted area, with only logged in accounts.

Will redirect if the session does not exists, you can set the boolean to true if you want to check the password in the database, for any password changes or something else.

this->cith->force(false);

cith's People

Contributors

heronbeluci avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.