This Laravel application implements user authentication, ensuring that certain routes are only accessible to authenticated users. It allows users to register, log in, and stay authenticated indefinitely (or until they manually log out).
- Protected Routes: Some routes require authentication.
- User Registration: Users can create an account to access protected routes.
- Persistent Authentication: Users can remain logged in indefinitely using the "Remember Me" feature.
- Public Post Listing: All posts are visible to every authenticated user.
- Creator Marker: Each post displays a "Created by: [User Name]" marker so you know who created the post.
- CRUD Operations:
- Create Post: Authenticated users can create new posts.
- Edit Post: Users can edit posts they have created.
- Delete Post: Users can delete posts they have created.
Ensure you have the following installed:
- PHP 8.x
- Composer
- Node.js & npm
- A database (MySQL, SQLite, etc.)
-
Clone the Repository
git clone https://github.com/itsMiniscule/security.git cd security -
Install Dependencies
composer install npm install && npm run build -
Configure Environment Variables
- Copy
.env.exampleto.env:cp .env.example .env
- Update the database settings in
.env:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_username DB_PASSWORD=your_password
- Copy
-
Generate Application Key
php artisan key:generate
-
Run Migrations
php artisan migrate
-
Start the Application
php artisan serve
Visit
http://127.0.0.1:8000in your browser.
- Users can register at
/register. - Upon successful registration, users are automatically logged in.
- Users can log in at
/login. - The "Remember Me" option keeps users logged in indefinitely.
- Routes requiring authentication are protected using the
authmiddleware. - Example:
Route::get('/dashboard', function () { return view('dashboard'); })->middleware('auth');
After logging in, all posts created by any user are visible. Each post displays the title, content, and a marker showing the name of the creator (e.g., "Created by: John Doe").
- Create Post: Use the "Create New Post" button to add a post.
- Edit Post: Posts you have created can be edited by clicking the "Edit" button.
- Delete Post: Posts you have created can be deleted by clicking the "Delete" button.
- Users can log out via
/logout, which invalidates their session.
This project is open-source under the MIT License.