Menu

Leaf Auth
Simple Authentication methods for faster development

Overview

Intro

Setting up a login and sign-up system can sometimes be a very unpleasant experience, especially for new devs. For pro devs, the challenge is "the standard". For this, Leaf has prepared something really simple.

Leaf Leaf Auth allows you to set-up authentication in just one line of code๐Ÿ˜…๐Ÿ˜…. Literally 1 line๐Ÿ˜Ž. To use Leaf Auth, you simply need to initialise the Leaf Auth package.

$auth = new Leaf\Core\Auth;

Authentication methods:

basicLogin()

Basic login is used to create a user login. It takes in a username and a password, it checks for the provided username and password in the users table of your database, so, for basicLogin to work, you need a users table. Also, the key for the data you pass in should be username and password. It returns the user data and a generated JSON Web Token.

$user = $auth->basicLogin("Mychi", "pACCw0R4");

If this data comes from a form, be sure to make the name options username and password

basicRegister()

Basic register is used to create a user register. It takes in a username, email, password and a password confirmation, it inserts the provided data into the users table of your database, so, for basicRegister to work, you need a users table.

$auth->basicRegister("Mychi", "mick@gmail.com", "pACCw0R4", "pACCw0R4");

After this, you can call the basicLogin method to get a token for the user
If this data comes from a form, be sure to make the name options username, email, password and confirm_password

Next Steps

Session
Simple Routing
Request
Response