Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2

After preparing the API backend and registration page discussed in article part 1. The next step is to create a login controller and create a login page to be able to access the main dashboard or system page.

To be able to follow this article well, you should first read the article CRUD Client Tutorial and Server API Using JQuery And Lumen Part 1

Make a Login Controller

Create a new controller with the name LoginController.php in the folder “app/Http/Controllers”. Copy the following code

Note:

To create a JWT token, some information will be encrypted with the secret key

Note:

iss: Issuer of the token
sub: Subject of the token
iat: time when JWT was issued
token: secret key token
exp : Expiration time

Create new Routes to access the login page API

Add the following code on “routes web.php”

Make a front-end login page

Please create a new file called index.php in the Restclient folder and copy the following code:

Note:

JQuery will access the API backend to log in the application with the address http://localhost:8000/login. If successful, JQuery will send an ajax request to register the user’s token and data profile into the PHP session in the file “set_authenticate.php”.

Create a file set_authenticate.php

Note:

If the login request on Server API has been successful, jQuery will continue to record tokens and user profiles in the PHP session used to handle page authentication in the client application.

If successful, JQuery will redirect the main “page/dashboard”.

Create a file with the name dashboard.php and copy the following code:

Until this section, the creation of the login page has been successful, to run the application please execute the API server with the following code

Then run the front-end application with the following URL

If successful, the application will run as shown below

Create Login Page With Jquery And Lumen Laravel Backend API Server

Until this step the login page has been completed, the last step is to create a dashboard page and create a CRUD application for the master item. Do not miss. Hopefully useful

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

1 Comment

 Add your comment
  1. Great tutorial man… awesome…
    now , i have more understanding about lumen concept…….

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.